diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-03-23 19:00:11 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-03-23 19:00:11 -0400 |
commit | 35c5fd3fba57a04ebd9083207875692bb92ac6d4 (patch) | |
tree | a7a3b968866e8af717ee66894004c4600e5e3dd6 /test/sql/test_query.py | |
parent | e69b9542a81a50545e4d4147c2053d126f4fe250 (diff) | |
download | sqlalchemy-35c5fd3fba57a04ebd9083207875692bb92ac6d4.tar.gz |
Fixed bug whereby a DBAPI that can return "0"
for cursor.lastrowid would not function correctly
in conjunction with :attr:`.ResultProxy.inserted_primary_key`.
Diffstat (limited to 'test/sql/test_query.py')
-rw-r--r-- | test/sql/test_query.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/sql/test_query.py b/test/sql/test_query.py index b5f50aeea..956a1165c 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -190,10 +190,27 @@ class QueryTest(fixtures.TestBase): try: table.create(bind=engine, checkfirst=True) i = insert_values(engine, table, values) - assert i == assertvalues, "tablename: %s %r %r" % (table.name, repr(i), repr(assertvalues)) + assert i == assertvalues, "tablename: %s %r %r" % + (table.name, repr(i), repr(assertvalues)) finally: table.drop(bind=engine) + @testing.only_on('sqlite+pysqlite') + @testing.provide_metadata + def test_lastrowid_zero(self): + from sqlalchemy.dialects import sqlite + eng = engines.testing_engine() + class ExcCtx(sqlite.base.SQLiteExecutionContext): + def get_lastrowid(self): + return 0 + eng.dialect.execution_ctx_cls = ExcCtx + t = Table('t', MetaData(), Column('x', Integer, primary_key=True), + Column('y', Integer)) + t.create(eng) + r = eng.execute(t.insert().values(y=5)) + eq_(r.inserted_primary_key, [0]) + + @testing.fails_on('sqlite', "sqlite autoincremnt doesn't work with composite pks") def test_misordered_lastrow(self): related = Table('related', metadata, |