summaryrefslogtreecommitdiff
path: root/test/sql/test_insert_exec.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-04-11 17:15:55 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-04-11 17:15:55 -0400
commit41de9a86c022250effbdd5aed4253df34628e103 (patch)
tree9ddf4e110803e1a7cfaa4e7e3c3e86b3609f33e2 /test/sql/test_insert_exec.py
parent7ea0d10c67b652895442c3a103e0813769309b9c (diff)
downloadsqlalchemy-41de9a86c022250effbdd5aed4253df34628e103.tar.gz
Return Row for CursorResult.inserted_primary_key
The tuple returned by :attr:`.CursorResult.inserted_primary_key` is now a :class:`_result.Row` object with a named tuple interface on top of the existing tuple interface. Fixes: #3314 Change-Id: I85677ef60d8329648f368bf497f634758f4e087b
Diffstat (limited to 'test/sql/test_insert_exec.py')
-rw-r--r--test/sql/test_insert_exec.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/test/sql/test_insert_exec.py b/test/sql/test_insert_exec.py
index ba763772c..76b4ba01e 100644
--- a/test/sql/test_insert_exec.py
+++ b/test/sql/test_insert_exec.py
@@ -112,9 +112,8 @@ class InsertExecTest(fixtures.TablesTest):
result = connection.execute(table_.insert(), values)
ret = values.copy()
- for col, id_ in zip(
- table_.primary_key, result.inserted_primary_key
- ):
+ ipk = result.inserted_primary_key
+ for col, id_ in zip(table_.primary_key, ipk):
ret[col.key] = id_
if result.lastrow_has_defaults():
@@ -131,7 +130,7 @@ class InsertExecTest(fixtures.TablesTest):
).first()
for c in table_.c:
ret[c.key] = row._mapping[c]
- return ret
+ return ret, ipk
if testing.against("firebird", "postgresql", "oracle", "mssql"):
assert testing.db.dialect.implicit_returning
@@ -147,8 +146,18 @@ class InsertExecTest(fixtures.TablesTest):
for engine in test_engines:
try:
table_.create(bind=engine, checkfirst=True)
- i = insert_values(engine, table_, values)
+ i, ipk = insert_values(engine, table_, values)
eq_(i, assertvalues)
+
+ # named tuple tests
+ for col in table_.primary_key:
+ eq_(getattr(ipk, col.key), assertvalues[col.key])
+ eq_(ipk._mapping[col.key], assertvalues[col.key])
+
+ eq_(
+ ipk._fields, tuple([col.key for col in table_.primary_key])
+ )
+
finally:
table_.drop(bind=engine)