summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2021-09-28 14:20:06 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-06-02 12:51:20 -0400
commit466ed5b53a3af83f337c93be95715e4b3ab1255e (patch)
tree73564b3a1d08e6b8add40c66a600625dd5f733fa /test/sql
parent7b6fb299bb6b47dfeb22a5650b95af7fa0b35ec2 (diff)
downloadsqlalchemy-466ed5b53a3af83f337c93be95715e4b3ab1255e.tar.gz
Generalize RETURNING and suppor for MariaDB / SQLite
As almost every dialect supports RETURNING now, RETURNING is also made more of a default assumption. * the default compiler generates a RETURNING clause now when specified; CompileError is no longer raised. * The dialect-level implicit_returning parameter now has no effect. It's not fully clear if there are real world cases relying on the dialect-level parameter, so we will see once 2.0 is released. ORM-level RETURNING can be disabled at the table level, and perhaps "implicit returning" should become an ORM-level option at some point as that's where it applies. * Altered ORM update() / delete() to respect table-level implicit returning for fetch. * Since MariaDB doesnt support UPDATE returning, "full_returning" is now split into insert_returning, update_returning, delete_returning * Crazy new thing. Dialects that have *both* cursor.lastrowid *and* returning. so now we can pick between them for SQLite and mariadb. so, we are trying to keep it on .lastrowid for simple inserts with an autoincrement column, this helps with some edge case test scenarios and i bet .lastrowid is faster anyway. any return_defaults() / multiparams etc then we use returning * SQLite decided they dont want to return rows that match in ON CONFLICT. this is flat out wrong, but for now we need to work with it. Fixes: #6195 Fixes: #7011 Closes: #7047 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7047 Pull-request-sha: d25d5ea3abe094f282c53c7dd87f5f53a9e85248 Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I9908ce0ff7bdc50bd5b27722081767c31c19a950
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_defaults.py21
-rw-r--r--test/sql/test_insert.py10
-rw-r--r--test/sql/test_insert_exec.py30
-rw-r--r--test/sql/test_returning.py313
-rw-r--r--test/sql/test_sequences.py26
-rw-r--r--test/sql/test_type_expressions.py2
6 files changed, 223 insertions, 179 deletions
diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py
index 0fa51e04c..08911a6c5 100644
--- a/test/sql/test_defaults.py
+++ b/test/sql/test_defaults.py
@@ -870,7 +870,7 @@ class DefaultRoundTripTest(fixtures.TablesTest):
class CTEDefaultTest(fixtures.TablesTest):
- __requires__ = ("ctes", "returning", "ctes_on_dml")
+ __requires__ = ("ctes", "insert_returning", "ctes_on_dml")
__backend__ = True
@classmethod
@@ -993,8 +993,11 @@ class PKDefaultTest(fixtures.TestBase):
return go
+ @testing.crashes(
+ "+mariadbconnector", "https://jira.mariadb.org/browse/CONPY-206"
+ )
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
@@ -1278,7 +1281,7 @@ class SpecialTypePKTest(fixtures.TestBase):
# we don't pre-fetch 'server_default'.
if "server_default" in kw and (
- not testing.db.dialect.implicit_returning
+ not testing.db.dialect.insert_returning
or not implicit_returning
):
eq_(r.inserted_primary_key, (None,))
@@ -1321,15 +1324,18 @@ class SpecialTypePKTest(fixtures.TestBase):
def test_server_default_no_autoincrement(self):
self._run_test(server_default="1", autoincrement=False)
+ @testing.crashes(
+ "+mariadbconnector", "https://jira.mariadb.org/browse/CONPY-206"
+ )
def test_clause(self):
stmt = select(cast("INT_1", type_=self.MyInteger)).scalar_subquery()
self._run_test(default=stmt)
- @testing.requires.returning
+ @testing.requires.insert_returning
def test_no_implicit_returning(self):
self._run_test(implicit_returning=False)
- @testing.requires.returning
+ @testing.requires.insert_returning
def test_server_default_no_implicit_returning(self):
self._run_test(server_default="1", autoincrement=False)
@@ -1363,7 +1369,7 @@ class ServerDefaultsOnPKTest(fixtures.TestBase):
eq_(r.inserted_primary_key, (None,))
eq_(list(connection.execute(t.select())), [("key_one", "data")])
- @testing.requires.returning
+ @testing.requires.insert_returning
@testing.provide_metadata
def test_string_default_on_insert_with_returning(self, connection):
"""With implicit_returning, we get a string PK default back no
@@ -1441,8 +1447,9 @@ class ServerDefaultsOnPKTest(fixtures.TestBase):
else:
eq_(list(connection.execute(t2.select())), [(5, "data")])
- @testing.requires.returning
+ @testing.requires.insert_returning
@testing.provide_metadata
+ @testing.fails_on("sqlite", "sqlite doesn't like our default trick here")
def test_int_default_on_insert_with_returning(self, connection):
metadata = self.metadata
t = Table(
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py
index 3a6217f67..808b047a2 100644
--- a/test/sql/test_insert.py
+++ b/test/sql/test_insert.py
@@ -332,10 +332,10 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
table1 = self.tables.mytable
stmt = table1.insert().returning(table1.c.myid)
- assert_raises_message(
- exc.CompileError,
- "RETURNING is not supported by this dialect's statement compiler.",
- stmt.compile,
+ self.assert_compile(
+ stmt,
+ "INSERT INTO mytable (myid, name, description) "
+ "VALUES (:myid, :name, :description) RETURNING mytable.myid",
dialect=default.DefaultDialect(),
)
@@ -1028,7 +1028,7 @@ class InsertImplicitReturningTest(
Column("q", Integer),
)
- dialect = postgresql.dialect(implicit_returning=True)
+ dialect = postgresql.dialect()
dialect.insert_null_pk_still_autoincrements = (
insert_null_still_autoincrements
)
diff --git a/test/sql/test_insert_exec.py b/test/sql/test_insert_exec.py
index 45f4098b2..3e51e9450 100644
--- a/test/sql/test_insert_exec.py
+++ b/test/sql/test_insert_exec.py
@@ -100,8 +100,9 @@ class InsertExecTest(fixtures.TablesTest):
# verify implicit_returning is working
if (
- connection.dialect.implicit_returning
+ connection.dialect.insert_returning
and table_.implicit_returning
+ and not connection.dialect.postfetch_lastrowid
):
ins = table_.insert()
comp = ins.compile(connection, column_keys=list(values))
@@ -146,7 +147,7 @@ class InsertExecTest(fixtures.TablesTest):
@testing.requires.supports_autoincrement_w_composite_pk
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
@@ -173,7 +174,7 @@ class InsertExecTest(fixtures.TablesTest):
@testing.requires.supports_autoincrement_w_composite_pk
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
@@ -200,7 +201,7 @@ class InsertExecTest(fixtures.TablesTest):
)
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
@@ -223,7 +224,7 @@ class InsertExecTest(fixtures.TablesTest):
@testing.requires.sequences
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
@@ -251,7 +252,7 @@ class InsertExecTest(fixtures.TablesTest):
@testing.requires.sequences
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
@@ -277,7 +278,7 @@ class InsertExecTest(fixtures.TablesTest):
)
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
@@ -299,7 +300,7 @@ class InsertExecTest(fixtures.TablesTest):
@testing.requires.supports_autoincrement_w_composite_pk
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
@@ -338,6 +339,7 @@ class InsertExecTest(fixtures.TablesTest):
self.metadata,
Column("x", Integer, primary_key=True),
Column("y", Integer),
+ implicit_returning=False,
)
t.create(connection)
with mock.patch.object(
@@ -403,12 +405,16 @@ class InsertExecTest(fixtures.TablesTest):
eq_(r.inserted_primary_key, (None,))
@testing.requires.empty_inserts
- @testing.requires.returning
- def test_no_inserted_pk_on_returning(self, connection):
+ @testing.requires.insert_returning
+ def test_no_inserted_pk_on_returning(
+ self, connection, close_result_when_finished
+ ):
users = self.tables.users
result = connection.execute(
users.insert().returning(users.c.user_id, users.c.user_name)
)
+ close_result_when_finished(result)
+
assert_raises_message(
exc.InvalidRequestError,
r"Can't call inserted_primary_key when returning\(\) is used.",
@@ -566,7 +572,7 @@ class TableInsertTest(fixtures.TablesTest):
inserted_primary_key=(1,),
)
- @testing.requires.returning
+ @testing.requires.insert_returning
def test_uppercase_direct_params_returning(self, connection):
t = self.tables.foo
self._test(
@@ -599,7 +605,7 @@ class TableInsertTest(fixtures.TablesTest):
inserted_primary_key=(),
)
- @testing.requires.returning
+ @testing.requires.insert_returning
def test_direct_params_returning(self, connection):
t = self._fixture()
self._test(
diff --git a/test/sql/test_returning.py b/test/sql/test_returning.py
index bacdbaf3f..c458e3262 100644
--- a/test/sql/test_returning.py
+++ b/test/sql/test_returning.py
@@ -199,8 +199,8 @@ class ReturnCombinationTests(fixtures.TestBase, AssertsCompiledSQL):
)
-class ReturningTest(fixtures.TablesTest, AssertsExecutionResults):
- __requires__ = ("returning",)
+class InsertReturningTest(fixtures.TablesTest, AssertsExecutionResults):
+ __requires__ = ("insert_returning",)
__backend__ = True
run_create_tables = "each"
@@ -286,26 +286,6 @@ class ReturningTest(fixtures.TablesTest, AssertsExecutionResults):
row = result.first()
eq_(row[0], 30)
- def test_update_returning(self, connection):
- table = self.tables.tables
- connection.execute(
- table.insert(),
- [{"persons": 5, "full": False}, {"persons": 3, "full": False}],
- )
-
- result = connection.execute(
- table.update()
- .values(dict(full=True))
- .where(table.c.persons > 4)
- .returning(table.c.id)
- )
- eq_(result.fetchall(), [(1,)])
-
- result2 = connection.execute(
- select(table.c.id, table.c.full).order_by(table.c.id)
- )
- eq_(result2.fetchall(), [(1, True), (2, False)])
-
@testing.fails_on(
"mssql",
"driver has unknown issue with string concatenation "
@@ -339,6 +319,94 @@ class ReturningTest(fixtures.TablesTest, AssertsExecutionResults):
)
eq_(result2.fetchall(), [(1, "FOOsomegoofyBAR")])
+ def test_no_ipk_on_returning(self, connection, close_result_when_finished):
+ table = self.tables.tables
+ result = connection.execute(
+ table.insert().returning(table.c.id), {"persons": 1, "full": False}
+ )
+ close_result_when_finished(result)
+ assert_raises_message(
+ sa_exc.InvalidRequestError,
+ r"Can't call inserted_primary_key when returning\(\) is used.",
+ getattr,
+ result,
+ "inserted_primary_key",
+ )
+
+ def test_insert_returning(self, connection):
+ table = self.tables.tables
+ result = connection.execute(
+ table.insert().returning(table.c.id), {"persons": 1, "full": False}
+ )
+
+ eq_(result.fetchall(), [(1,)])
+
+ @testing.requires.multivalues_inserts
+ def test_multirow_returning(self, connection):
+ table = self.tables.tables
+ ins = (
+ table.insert()
+ .returning(table.c.id, table.c.persons)
+ .values(
+ [
+ {"persons": 1, "full": False},
+ {"persons": 2, "full": True},
+ {"persons": 3, "full": False},
+ ]
+ )
+ )
+ result = connection.execute(ins)
+ eq_(result.fetchall(), [(1, 1), (2, 2), (3, 3)])
+
+ @testing.fails_on_everything_except(
+ "postgresql", "mariadb>=10.5", "sqlite>=3.34"
+ )
+ def test_literal_returning(self, connection):
+ if testing.against("mariadb"):
+ quote = "`"
+ else:
+ quote = '"'
+ if testing.against("postgresql"):
+ literal_true = "true"
+ else:
+ literal_true = "1"
+
+ result4 = connection.exec_driver_sql(
+ "insert into tables (id, persons, %sfull%s) "
+ "values (5, 10, %s) returning persons"
+ % (quote, quote, literal_true)
+ )
+ eq_([dict(row._mapping) for row in result4], [{"persons": 10}])
+
+
+class UpdateReturningTest(fixtures.TablesTest, AssertsExecutionResults):
+ __requires__ = ("update_returning",)
+ __backend__ = True
+
+ run_create_tables = "each"
+
+ define_tables = InsertReturningTest.define_tables
+
+ def test_update_returning(self, connection):
+ table = self.tables.tables
+ connection.execute(
+ table.insert(),
+ [{"persons": 5, "full": False}, {"persons": 3, "full": False}],
+ )
+
+ result = connection.execute(
+ table.update()
+ .values(dict(full=True))
+ .where(table.c.persons > 4)
+ .returning(table.c.id)
+ )
+ eq_(result.fetchall(), [(1,)])
+
+ result2 = connection.execute(
+ select(table.c.id, table.c.full).order_by(table.c.id)
+ )
+ eq_(result2.fetchall(), [(1, True), (2, False)])
+
def test_update_returning_w_expression_one(self, connection):
table = self.tables.tables
connection.execute(
@@ -388,7 +456,6 @@ class ReturningTest(fixtures.TablesTest, AssertsExecutionResults):
[(1, "FOOnewgoofyBAR"), (2, "FOOsomegoofy2BAR")],
)
- @testing.requires.full_returning
def test_update_full_returning(self, connection):
table = self.tables.tables
connection.execute(
@@ -404,69 +471,14 @@ class ReturningTest(fixtures.TablesTest, AssertsExecutionResults):
)
eq_(result.fetchall(), [(1, True), (2, True)])
- @testing.requires.full_returning
- def test_delete_full_returning(self, connection):
- table = self.tables.tables
- connection.execute(
- table.insert(),
- [{"persons": 5, "full": False}, {"persons": 3, "full": False}],
- )
-
- result = connection.execute(
- table.delete().returning(table.c.id, table.c.full)
- )
- eq_(result.fetchall(), [(1, False), (2, False)])
-
- def test_insert_returning(self, connection):
- table = self.tables.tables
- result = connection.execute(
- table.insert().returning(table.c.id), {"persons": 1, "full": False}
- )
- eq_(result.fetchall(), [(1,)])
-
- @testing.requires.multivalues_inserts
- def test_multirow_returning(self, connection):
- table = self.tables.tables
- ins = (
- table.insert()
- .returning(table.c.id, table.c.persons)
- .values(
- [
- {"persons": 1, "full": False},
- {"persons": 2, "full": True},
- {"persons": 3, "full": False},
- ]
- )
- )
- result = connection.execute(ins)
- eq_(result.fetchall(), [(1, 1), (2, 2), (3, 3)])
-
- def test_no_ipk_on_returning(self, connection):
- table = self.tables.tables
- result = connection.execute(
- table.insert().returning(table.c.id), {"persons": 1, "full": False}
- )
- assert_raises_message(
- sa_exc.InvalidRequestError,
- r"Can't call inserted_primary_key when returning\(\) is used.",
- getattr,
- result,
- "inserted_primary_key",
- )
+class DeleteReturningTest(fixtures.TablesTest, AssertsExecutionResults):
+ __requires__ = ("delete_returning",)
+ __backend__ = True
- @testing.fails_on_everything_except("postgresql")
- def test_literal_returning(self, connection):
- if testing.against("postgresql"):
- literal_true = "true"
- else:
- literal_true = "1"
+ run_create_tables = "each"
- result4 = connection.exec_driver_sql(
- 'insert into tables (id, persons, "full") '
- "values (5, 10, %s) returning persons" % literal_true
- )
- eq_([dict(row._mapping) for row in result4], [{"persons": 10}])
+ define_tables = InsertReturningTest.define_tables
def test_delete_returning(self, connection):
table = self.tables.tables
@@ -487,7 +499,7 @@ class ReturningTest(fixtures.TablesTest, AssertsExecutionResults):
class CompositeStatementTest(fixtures.TestBase):
- __requires__ = ("returning",)
+ __requires__ = ("insert_returning",)
__backend__ = True
@testing.provide_metadata
@@ -517,7 +529,7 @@ class CompositeStatementTest(fixtures.TestBase):
class SequenceReturningTest(fixtures.TablesTest):
- __requires__ = "returning", "sequences"
+ __requires__ = "insert_returning", "sequences"
__backend__ = True
@classmethod
@@ -552,7 +564,7 @@ class KeyReturningTest(fixtures.TablesTest, AssertsExecutionResults):
"""test returning() works with columns that define 'key'."""
- __requires__ = ("returning",)
+ __requires__ = ("insert_returning",)
__backend__ = True
@classmethod
@@ -583,8 +595,8 @@ class KeyReturningTest(fixtures.TablesTest, AssertsExecutionResults):
assert row[table.c.foo_id] == row["id"] == 1
-class ReturnDefaultsTest(fixtures.TablesTest):
- __requires__ = ("returning",)
+class InsertReturnDefaultsTest(fixtures.TablesTest):
+ __requires__ = ("insert_returning",)
run_define_tables = "each"
__backend__ = True
@@ -639,67 +651,99 @@ class ReturnDefaultsTest(fixtures.TablesTest):
[1, 0],
)
- def test_chained_update_pk(self, connection):
+ def test_insert_non_default(self, connection):
+ """test that a column not marked at all as a
+ default works with this feature."""
+
t1 = self.tables.t1
- connection.execute(t1.insert().values(upddef=1))
result = connection.execute(
- t1.update().values(data="d1").return_defaults(t1.c.upddef)
+ t1.insert().values(upddef=1).return_defaults(t1.c.data)
)
eq_(
- [result.returned_defaults._mapping[k] for k in (t1.c.upddef,)], [1]
+ [
+ result.returned_defaults._mapping[k]
+ for k in (t1.c.id, t1.c.data)
+ ],
+ [1, None],
)
- def test_arg_update_pk(self, connection):
+ def test_insert_sql_expr(self, connection):
+ from sqlalchemy import literal
+
t1 = self.tables.t1
- connection.execute(t1.insert().values(upddef=1))
result = connection.execute(
- t1.update().return_defaults(t1.c.upddef).values(data="d1")
+ t1.insert().return_defaults().values(insdef=literal(10) + 5)
)
+
eq_(
- [result.returned_defaults._mapping[k] for k in (t1.c.upddef,)], [1]
+ result.returned_defaults._mapping,
+ {"id": 1, "data": None, "insdef": 15, "upddef": None},
)
- def test_insert_non_default(self, connection):
- """test that a column not marked at all as a
- default works with this feature."""
+ def test_insert_non_default_plus_default(self, connection):
+ t1 = self.tables.t1
+ result = connection.execute(
+ t1.insert()
+ .values(upddef=1)
+ .return_defaults(t1.c.data, t1.c.insdef)
+ )
+ eq_(
+ dict(result.returned_defaults._mapping),
+ {"id": 1, "data": None, "insdef": 0},
+ )
+ eq_(result.inserted_primary_key, (1,))
+ def test_insert_all(self, connection):
t1 = self.tables.t1
result = connection.execute(
- t1.insert().values(upddef=1).return_defaults(t1.c.data)
+ t1.insert().values(upddef=1).return_defaults()
)
eq_(
- [
- result.returned_defaults._mapping[k]
- for k in (t1.c.id, t1.c.data)
- ],
- [1, None],
+ dict(result.returned_defaults._mapping),
+ {"id": 1, "data": None, "insdef": 0},
)
+ eq_(result.inserted_primary_key, (1,))
- def test_update_non_default(self, connection):
- """test that a column not marked at all as a
- default works with this feature."""
+class UpdatedReturnDefaultsTest(fixtures.TablesTest):
+ __requires__ = ("update_returning",)
+ run_define_tables = "each"
+ __backend__ = True
+
+ define_tables = InsertReturnDefaultsTest.define_tables
+
+ def test_chained_update_pk(self, connection):
t1 = self.tables.t1
connection.execute(t1.insert().values(upddef=1))
result = connection.execute(
- t1.update().values(upddef=2).return_defaults(t1.c.data)
+ t1.update().values(data="d1").return_defaults(t1.c.upddef)
)
eq_(
- [result.returned_defaults._mapping[k] for k in (t1.c.data,)],
- [None],
+ [result.returned_defaults._mapping[k] for k in (t1.c.upddef,)], [1]
)
- def test_insert_sql_expr(self, connection):
- from sqlalchemy import literal
-
+ def test_arg_update_pk(self, connection):
t1 = self.tables.t1
+ connection.execute(t1.insert().values(upddef=1))
result = connection.execute(
- t1.insert().return_defaults().values(insdef=literal(10) + 5)
+ t1.update().return_defaults(t1.c.upddef).values(data="d1")
)
+ eq_(
+ [result.returned_defaults._mapping[k] for k in (t1.c.upddef,)], [1]
+ )
+
+ def test_update_non_default(self, connection):
+ """test that a column not marked at all as a
+ default works with this feature."""
+ t1 = self.tables.t1
+ connection.execute(t1.insert().values(upddef=1))
+ result = connection.execute(
+ t1.update().values(upddef=2).return_defaults(t1.c.data)
+ )
eq_(
- result.returned_defaults._mapping,
- {"id": 1, "data": None, "insdef": 15, "upddef": None},
+ [result.returned_defaults._mapping[k] for k in (t1.c.data,)],
+ [None],
)
def test_update_sql_expr(self, connection):
@@ -713,19 +757,6 @@ class ReturnDefaultsTest(fixtures.TablesTest):
eq_(result.returned_defaults._mapping, {"upddef": 15})
- def test_insert_non_default_plus_default(self, connection):
- t1 = self.tables.t1
- result = connection.execute(
- t1.insert()
- .values(upddef=1)
- .return_defaults(t1.c.data, t1.c.insdef)
- )
- eq_(
- dict(result.returned_defaults._mapping),
- {"id": 1, "data": None, "insdef": 0},
- )
- eq_(result.inserted_primary_key, (1,))
-
def test_update_non_default_plus_default(self, connection):
t1 = self.tables.t1
connection.execute(t1.insert().values(upddef=1))
@@ -739,17 +770,6 @@ class ReturnDefaultsTest(fixtures.TablesTest):
{"data": None, "upddef": 1},
)
- def test_insert_all(self, connection):
- t1 = self.tables.t1
- result = connection.execute(
- t1.insert().values(upddef=1).return_defaults()
- )
- eq_(
- dict(result.returned_defaults._mapping),
- {"id": 1, "data": None, "insdef": 0},
- )
- eq_(result.inserted_primary_key, (1,))
-
def test_update_all(self, connection):
t1 = self.tables.t1
connection.execute(t1.insert().values(upddef=1))
@@ -758,7 +778,14 @@ class ReturnDefaultsTest(fixtures.TablesTest):
)
eq_(dict(result.returned_defaults._mapping), {"upddef": 1})
- @testing.requires.insert_executemany_returning
+
+class InsertManyReturnDefaultsTest(fixtures.TablesTest):
+ __requires__ = ("insert_executemany_returning",)
+ run_define_tables = "each"
+ __backend__ = True
+
+ define_tables = InsertReturnDefaultsTest.define_tables
+
def test_insert_executemany_no_defaults_passed(self, connection):
t1 = self.tables.t1
result = connection.execute(
@@ -802,7 +829,6 @@ class ReturnDefaultsTest(fixtures.TablesTest):
lambda: result.inserted_primary_key,
)
- @testing.requires.insert_executemany_returning
def test_insert_executemany_insdefault_passed(self, connection):
t1 = self.tables.t1
result = connection.execute(
@@ -846,7 +872,6 @@ class ReturnDefaultsTest(fixtures.TablesTest):
lambda: result.inserted_primary_key,
)
- @testing.requires.insert_executemany_returning
def test_insert_executemany_only_pk_passed(self, connection):
t1 = self.tables.t1
result = connection.execute(
diff --git a/test/sql/test_sequences.py b/test/sql/test_sequences.py
index be74153ce..19f95c661 100644
--- a/test/sql/test_sequences.py
+++ b/test/sql/test_sequences.py
@@ -218,9 +218,15 @@ class SequenceExecTest(fixtures.TestBase):
@testing.combinations(
("implicit_returning",),
("no_implicit_returning",),
- ("explicit_returning", testing.requires.returning),
- ("return_defaults_no_implicit_returning", testing.requires.returning),
- ("return_defaults_implicit_returning", testing.requires.returning),
+ ("explicit_returning", testing.requires.insert_returning),
+ (
+ "return_defaults_no_implicit_returning",
+ testing.requires.insert_returning,
+ ),
+ (
+ "return_defaults_implicit_returning",
+ testing.requires.insert_returning,
+ ),
argnames="returning",
)
@testing.requires.multivalues_inserts
@@ -264,17 +270,17 @@ class SequenceExecTest(fixtures.TestBase):
("no_implicit_returning",),
(
"explicit_returning",
- testing.requires.returning
+ testing.requires.insert_returning
+ testing.requires.insert_executemany_returning,
),
(
"return_defaults_no_implicit_returning",
- testing.requires.returning
+ testing.requires.insert_returning
+ testing.requires.insert_executemany_returning,
),
(
"return_defaults_implicit_returning",
- testing.requires.returning
+ testing.requires.insert_returning
+ testing.requires.insert_executemany_returning,
),
argnames="returning",
@@ -318,7 +324,7 @@ class SequenceExecTest(fixtures.TestBase):
[(1, "d1"), (2, "d2"), (3, "d3")],
)
- @testing.requires.returning
+ @testing.requires.insert_returning
def test_inserted_pk_implicit_returning(self, connection, metadata):
"""test inserted_primary_key contains the result when
pk_col=next_value(), when implicit returning is used."""
@@ -435,7 +441,7 @@ class SequenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
assert not self._has_sequence(connection, "s1")
assert not self._has_sequence(connection, "s2")
- @testing.requires.returning
+ @testing.requires.insert_returning
@testing.requires.supports_sequence_for_autoincrement_column
@testing.provide_metadata
def test_freestanding_sequence_via_autoinc(self, connection):
@@ -545,7 +551,7 @@ class TableBoundSequenceTest(fixtures.TablesTest):
return go
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
@@ -571,7 +577,7 @@ class TableBoundSequenceTest(fixtures.TablesTest):
)
@testing.combinations(
- (True, testing.requires.returning),
+ (True, testing.requires.insert_returning),
(False,),
argnames="implicit_returning",
)
diff --git a/test/sql/test_type_expressions.py b/test/sql/test_type_expressions.py
index 70c8839e3..901be7132 100644
--- a/test/sql/test_type_expressions.py
+++ b/test/sql/test_type_expressions.py
@@ -496,7 +496,7 @@ class TypeDecRoundTripTest(fixtures.TablesTest, RoundTripTestBase):
class ReturningTest(fixtures.TablesTest):
- __requires__ = ("returning",)
+ __requires__ = ("insert_returning",)
@classmethod
def define_tables(cls, metadata):