Code

Opened 6 years ago

Closed 6 years ago

#6901 closed (invalid)

Test failures with SQLite (?)

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

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by brodie

db.models.base with updated extra/order_by usage

comment:1 Changed 6 years ago by brodie

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 6 years ago by brodie

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

comment:2 Changed 6 years ago by brodie

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 6 years ago by mtredinnick

  • 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 6 years ago by mtredinnick

  • Keywords qs-rf removed
  • Summary changed from Old QuerySet.extra().order_by() API is used in Model to Test 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 6 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.