Opened 4 years ago

Closed 2 years ago

#18320 closed Bug (worksforme)

Unit test model_formsets_regress.FormsetTests.test_extraneous_query_is_not_run expects wrong number of queries

Reported by: Michael Manfre Owned by: nobody
Component: Testing framework Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

For database backends with feature can_return_id_from_insert = False, there should be an expected second query, which fetches the newly inserted pk.

Attachments (2)

django-ticket18320.diff (1.1 KB) - added by Michael Manfre 4 years ago.
Check conection features to determine proper num of expected queries.
django-ticket18320.2.diff (1.5 KB) - added by Michael Manfre 4 years ago.
Added feature 'query_needed_to_fetch_return_id'

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by Michael Manfre

Attachment: django-ticket18320.diff added

Check conection features to determine proper num of expected queries.

comment:1 Changed 4 years ago by Anssi Kääriäinen

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Looks good. But why does this test not fail on any of core backends?

Not marking as RFC as I haven't actually applied the patch.

comment:2 Changed 4 years ago by Michael Manfre

Patch needs improvement: set

You raised a valid question. can_return_id_from_insert = False does not necessarily imply that a separate query is needed to fetch the return_id. Updating patch pending.

Changed 4 years ago by Michael Manfre

Attachment: django-ticket18320.2.diff added

Added feature 'query_needed_to_fetch_return_id'

comment:3 Changed 4 years ago by Michael Manfre

Patch needs improvement: unset

The other backends are able to pull the insert id from the cursor without an additional query.

comment:4 Changed 2 years ago by Tim Graham

Is this still desired or did you find another solution in the past 2 years? It looks like it was just forgotten.

comment:5 Changed 2 years ago by Michael Manfre

Resolution: worksforme
Status: newclosed

I found another solution and forgot about this case. Closing.

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