Opened 9 years ago

Closed 9 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: UI/UX:

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 9 years ago.
db.models.base with updated extra/order_by usage
extra-orderby-2.diff (1.3 KB) - added by Brodie Rao 9 years ago.
db.models.base with updated extra/order_by usage (uses .values() as before)

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by Brodie Rao

Attachment: extra-orderby.diff added

db.models.base with updated extra/order_by usage

comment:1 Changed 9 years ago by Brodie Rao

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.

Changed 9 years ago by Brodie Rao

Attachment: extra-orderby-2.diff added

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

comment:2 Changed 9 years ago by Brodie Rao

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 Changed 9 years ago by Malcolm Tredinnick

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 Changed 9 years ago by Malcolm Tredinnick

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 Changed 9 years ago by Malcolm Tredinnick

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