MSSQL session.flush() doesn't always fetch primary keys

Issue #415 resolved
Former user created an issue

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)

  1. paj

    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.

  2. Former user 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.

  3. Former user 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.

  4. paj

    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.

  5. Log in to comment