Opened 14 years ago
Closed 11 years ago
#14300 closed Bug (fixed)
manage.py sqlcustom fails if models are in a submodule
Reported by: | David Rogers | Owned by: | Fede Heinz |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.2 |
Severity: | Normal | Keywords: | |
Cc: | emyller@…, timograham@…, vlastimil@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This is similar to #6961, from what I've seen. According to the docs for 1.2:
Django provides a hook for passing the database arbitrary SQL that's executed just after the CREATE TABLE statements when you run syncdb. You can use this hook to populate default records, or you could also create SQL functions, views, triggers, etc. The hook is simple: Django just looks for a file called sql/<modelname>.sql, in your app directory, where <modelname> is the model's name in lowercase.
This doesn't work when the "models" module is a directory instead of a file, i.e. project/application/models/
vice project/application/models.py
. Apparently, sqlcustom
is using similar logic to what was described in #6961, since I can move my sql/
directory into the models/
directory - a la project/application/models/sql/
- and everything works.
Attachments (1)
Change History (14)
comment:1 by , 14 years ago
Owner: | changed from | to
---|
by , 14 years ago
Attachment: | customsql_model_package.patch added |
---|
comment:2 by , 14 years ago
Has patch: | set |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Triage Stage: | Unreviewed → Accepted |
The attached patch fixes the bug, and adds tests to check that both cases (models module is a directory or a file) work.
comment:3 by , 14 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Reopening. The fixed status is set when a commit lands in the code repository.
comment:4 by , 14 years ago
Patch needs improvement: | set |
---|---|
Severity: | → Normal |
Type: | → Bug |
Unittests are now preferred over doctests in the django codebase. Could you rewrite your tests accordingly? Thanks!
comment:7 by , 13 years ago
Cc: | added |
---|
comment:9 by , 12 years ago
Status: | reopened → new |
---|
comment:10 by , 11 years ago
Cc: | added |
---|---|
Patch needs improvement: | unset |
follow-up: 12 comment:11 by , 11 years ago
comment:12 by , 11 years ago
Cc: | added |
---|
Replying to timo:
Also reported in #15519 the PR there addresses backwards incompatibility by searching both
app/sql
andapp/models/sql
with aDeprecationWarning
if the latter is used. I'm not a huge fan of adding extra code and tests to support that for a release or two, but I'll do it if necessary.
In ticket:15519#comment:2 jacob required to use both locations. My patch also contains a test. The patch does not apply, because of all the changes in tests, but it should be easy to fix.
Edit: Fix the comment link.
comment:13 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixes the bug, adds tests