Skip to content

Fixed #18347 -- Wrapped raw identity inserts in tests. #82

Closed
wants to merge 1 commit into from

2 participants

@manfre
manfre commented May 18, 2012

Added enable_identity_insert, disable_identity_insert, and
contextmanager identity_insert_enabled to DatabaseOperations for
database backends that need to take special actions to allow
identity inserts.

All raw insert statements that set a value in to the identity field
should include these guards to allow all database backends to
function.

@manfre manfre Fixed #18347 -- Wrapped raw identity inserts in tests.
Added enable_identity_insert, disable_identity_insert, and
contextmanager identity_insert_enabled to DatabaseOperations for
database backends that need to take special actions to allow
identity inserts.

All raw insert statements that set a value in to the identity field
should include these guards to allow all database backends to
function.
06d8aee
@akaariai
Django member

Three comments:

  • What is the use of the "enabled" flag in the enable_identity_inserts manager? Is there some use case where calling the disable part would be wrong depending on the return value of the enable step?
  • The naming: identity_insert_enabled -> autofield_inserts_enabled: Django does not know of identity, it deals with autofields (other references to identity should be changed to identity, too).
  • Add a little more comments to enable_identity_insert, telling that no core backend needs these methods, but for example mssql needs them.

So, seems good apart of the usual final nitpicking...

BTW it seems I will be real busy for the next couple of weeks - I intend to work on all of the MSSQL patches, but I can't do that now. Of course, if somebody else wants to commit these I have no objections to that...

@akaariai
Django member
akaariai commented Jun 8, 2012

I have added another patch into the ticket. I will close this PR until we see which way to take here. I can take this PR forward without any further editing by manfre if we choose this route.

@akaariai akaariai closed this Jun 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.