diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-06-23 15:55:39 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-06-23 15:55:39 +0000 |
| commit | 660a340bff8fcefd2826032e75210c0924a2335e (patch) | |
| tree | 09dad6493898b02ed14566644c2feae12136b20b /test/sql | |
| parent | fbb455e2e520828627324297a48e24e92d2b48a8 (diff) | |
| parent | 62be25cdfaab377319602a1852a1fddcbf6acd45 (diff) | |
| download | sqlalchemy-660a340bff8fcefd2826032e75210c0924a2335e.tar.gz | |
Merge "Propose using RETURNING for bulk updates, deletes"
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_returning.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/test/sql/test_returning.py b/test/sql/test_returning.py index f856c15a4..90c21ed45 100644 --- a/test/sql/test_returning.py +++ b/test/sql/test_returning.py @@ -129,6 +129,32 @@ class ReturningTest(fixtures.TestBase, AssertsExecutionResults): ) eq_(result2.fetchall(), [(1, True), (2, False)]) + @testing.requires.full_returning + def test_update_full_returning(self, connection): + connection.execute( + table.insert(), + [{"persons": 5, "full": False}, {"persons": 3, "full": False}], + ) + + result = connection.execute( + table.update(table.c.persons > 2) + .values(full=True) + .returning(table.c.id, table.c.full) + ) + eq_(result.fetchall(), [(1, True), (2, True)]) + + @testing.requires.full_returning + def test_delete_full_returning(self, connection): + 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): result = connection.execute( table.insert().returning(table.c.id), {"persons": 1, "full": False} @@ -474,13 +500,6 @@ class ImplicitReturningFlag(fixtures.TestBase): testing.requires.returning(go)() e = engines.testing_engine() - # starts as False. This is because all of Firebird, - # PostgreSQL, Oracle, SQL Server started supporting RETURNING - # as of a certain version, and the flag is not set until - # version detection occurs. If some DB comes along that has - # RETURNING in all cases, this test can be adjusted. - assert e.dialect.implicit_returning is False - # version detection on connect sets it c = e.connect() c.close() |
