From: Brad Allen Date: Tue, 9 Mar 2010 00:19:25 +0000 (-0600) Subject: Added docstring & comments explaining test_fetchid_trigger X-Git-Tag: rel_0_6beta2~64 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e96a7c90e2ab9ad4cfbc5e4bcf8da53ab08b9c17;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Added docstring & comments explaining test_fetchid_trigger --- diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py index f7728c8845..9846d81d56 100644 --- a/test/dialect/test_mssql.py +++ b/test/dialect/test_mssql.py @@ -356,11 +356,37 @@ class QueryTest(TestBase): __only_on__ = 'mssql' def test_fetchid_trigger(self): + """ + Verify the identity return value when inserting to a table + with an insert trigger, which triggers another insert to + a different table. + + The OUTPUT INSERTED clause which is normally used + to return the identity value won't work for this case, + because of the following error: + + ProgrammingError: (ProgrammingError) ('42000', 334, + "[Microsoft][SQL Server Native Client 10.0][SQL Server]The + target table 't1' of the DML statement cannot have any enabled + triggers if the statement contains an OUTPUT clause without + INTO clause.", 7748) 'INSERT INTO t1 (descr) OUTPUT inserted.id + VALUES (?)' ('hello',) + + This means the connector needs a backup plan; the execution + should use SCOPE_IDENTITY() + + todo: this same test needs to be tried in a multithreaded context + with multiple threads inserting to the same table. + """ meta = MetaData(testing.db) t1 = Table('t1', meta, Column('id', Integer, Sequence('fred', 100, 1), primary_key=True), Column('descr', String(200)), - implicit_returning = False + # the following flag will prevent the MSSQLCompiler.returning_clause + # from getting called, though the ExecutionContext will still have + # a _select_lastrowid, so the SELECT SCOPE_IDENTITY() will hopefully + # be called instead. + implicit_returning = False ) t2 = Table('t2', meta, Column('id', Integer, Sequence('fred', 200, 1), primary_key=True),