Opened 17 years ago

Closed 17 years ago

#6901 closed (invalid)

Test failures with SQLite (?)

Reported by: Brodie Rao Owned by: nobody
Component: Database layer (models, ORM) Version: queryset-refactor
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

db.models.base.Model uses the old the QuerySet.extra().order_by(), instead of using QuerySet.extra(..., order_by=...). This causes a slew of tests to fail with "PRIMARY KEY must be unique" on sqlite3, and maybe other backends too. Changing it to use the new API fixes all failing tests with sqlite3.

Attachments (2)

extra-orderby.diff (1.3 KB ) - added by Brodie Rao 17 years ago.
db.models.base with updated extra/order_by usage
extra-orderby-2.diff (1.3 KB ) - added by Brodie Rao 17 years ago.
db.models.base with updated extra/order_by usage (uses .values() as before)

Download all attachments as: .zip

Change History (7)

by Brodie Rao, 17 years ago

Attachment: extra-orderby.diff added

db.models.base with updated extra/order_by usage

comment:1 by Brodie Rao, 17 years ago

Actually, the first change leaves out the call to .values(), but the tests will fail again with .values() added unless you apply the updated patch from #6899, which fixes boolean evaluation of ValuesQuerySets. I'm attaching a patch with .values() added back in.

by Brodie Rao, 17 years ago

Attachment: extra-orderby-2.diff added

db.models.base with updated extra/order_by usage (uses .values() as before)

comment:2 by Brodie Rao, 17 years ago

Just to follow up: This issue didn't affect the mysql and postgresql_psycopg2 backends. All tests pass on both backends with or without the patches.

comment:3 by Malcolm Tredinnick, 17 years ago

Has patch: unset

Which tests do you see failing with SQLite? Since I run the SQLite tests for this branch many times each day when I'm working on it and I see nothing failing there's something else going on here.

The patch you've given has no effect on functionality and only slows things down (the original code just makes sure to remove all ordering, your patch adds in some ordering). There is nothing wrong with using order_by() with extra(), providing you aren't trying to order by one of the extra bits, so the current use in the branch is correct.

I think there's something else going on here from what you expect. Please provide more details. Removing 'has_patch' flag, since this patch doesn't fix any problem that exists and makes the queries less efficient.

comment:4 by Malcolm Tredinnick, 17 years ago

Keywords: qs-rf removed
Summary: Old QuerySet.extra().order_by() API is used in ModelTest failures with SQLite (?)

Changing title to reflect the current status of the problem. Can't go any further on this without more information.

comment:5 by Malcolm Tredinnick, 17 years ago

Resolution: invalid
Status: newclosed

Closing, based on lack of additional information (and the fact that the SQLite tests are passing for everybody else I know, including myself).

Please reopen if you have information about your particular setup that may shed light on the failing tests. A list of failing tests is important to have, too.

Note: See TracTickets for help on using tickets.
Back to Top