MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_lastrowid_zero

Method test_lastrowid_zero

test/sql/test_insert_exec.py:378–397  ·  view source on GitHub ↗
(self, metadata, connection)

Source from the content-addressed store, hash-verified

376 # TODO: why not in the sqlite suite?
377 @testing.only_on("sqlite+pysqlite")
378 def test_lastrowid_zero(self, metadata, connection):
379 from sqlalchemy.dialects import sqlite
380
381 class ExcCtx(sqlite.base.SQLiteExecutionContext):
382 def get_lastrowid(self):
383 return 0
384
385 t = Table(
386 "t",
387 self.metadata,
388 Column("x", Integer, primary_key=True),
389 Column("y", Integer),
390 implicit_returning=False,
391 )
392 t.create(connection)
393 with mock.patch.object(
394 connection.dialect, "execution_ctx_cls", ExcCtx
395 ):
396 r = connection.execute(t.insert().values(y=5))
397 eq_(r.inserted_primary_key, (0,))
398
399 @testing.requires.supports_autoincrement_w_composite_pk
400 def test_misordered_lastrow(self, connection, metadata):

Callers

nothing calls this directly

Calls 8

createMethod · 0.95
TableClass · 0.90
ColumnClass · 0.90
eq_Function · 0.90
objectMethod · 0.80
executeMethod · 0.45
valuesMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected