- attached bug4.py
MSSQL session.flush() doesn't always fetch primary keys
When using MSSQL, session.flush() doesn't always fetch the primary key just inserted. It does if you define the Column with a Sequence parameter, but if you just say primary_key=True and leave SA to automatically generate a sequence, the primary key won't be fetched on session.flush().
Comments (10)
-
-
- attached mssql-autoid.patch
Proposed fix, including unit test
-
I've created a fairly simple fix for this, that only changes behaviour on MSSQL. As well as fixing the reported bug, it stops MSSQLSchemaGenerator altering the table definition.
-
Account Deleted (original author: ram) Why does the patch drop the check for foreign keys and DEFAULT checks?
It seems to me that a column that is a foreign key makes no sense as an IDENTITY column, nor one with a non-optional column default.
-
Account Deleted (original author: ram) I'll commit a patch that checks for this on queries providing that it doesn't affect performance greatly (by doing the column calculations once and storing them on the Table object, thereafter only checking a flag), and includes the exceptions for Foreign keys and non-optional DEFAULT checks.
-
Ok, after a bit of a break, here at last is a patch that will (hopefully) meet the grade. It includes a new unit test to verify the fix.
-
- attached mssql-autoid-2.patch
Proposed fix (please ignore mssql-autoid.patch)
-
Account Deleted - changed status to resolved
(original author: ram) This one looks a lot better. Committed in rev 2324, thanks.
-
repo owner - changed milestone to 0.4.0
Milestone next micropoint release deleted
-
repo owner - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment
minimal test case