diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2021-11-07 21:19:45 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-11-07 21:19:45 +0000 |
| commit | 201c00bc0837af831f115e8313ad3ccb0be97e7a (patch) | |
| tree | beb7558e95d073b63fa4bb76d830ccaa2de9711a /test/sql | |
| parent | 5b1c9053b0903b2d5a06f82b47fe16a870696ddc (diff) | |
| parent | d050193daaa8d91371c759296f3304b8641c1976 (diff) | |
| download | sqlalchemy-201c00bc0837af831f115e8313ad3ccb0be97e7a.tar.gz | |
Merge "fully implement future engine and remove legacy" into main
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_compiler.py | 26 | ||||
| -rw-r--r-- | test/sql/test_cte.py | 16 | ||||
| -rw-r--r-- | test/sql/test_defaults.py | 7 | ||||
| -rw-r--r-- | test/sql/test_deprecations.py | 133 | ||||
| -rw-r--r-- | test/sql/test_resultset.py | 4 | ||||
| -rw-r--r-- | test/sql/test_sequences.py | 10 |
6 files changed, 14 insertions, 182 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 4c8b1a434..3ced05df2 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -4926,38 +4926,36 @@ class KwargPropagationTest(fixtures.TestBase): class ExecutionOptionsTest(fixtures.TestBase): def test_non_dml(self): - stmt = table1.select() + stmt = table1.select().execution_options(foo="bar") compiled = stmt.compile() - eq_(compiled.execution_options, {}) + eq_(compiled.execution_options, {"foo": "bar"}) def test_dml(self): - stmt = table1.insert() + stmt = table1.insert().execution_options(foo="bar") compiled = stmt.compile() - eq_(compiled.execution_options, {"autocommit": True}) + eq_(compiled.execution_options, {"foo": "bar"}) def test_embedded_element_true_to_none(self): - stmt = table1.insert() - eq_(stmt._execution_options, {"autocommit": True}) + stmt = table1.insert().execution_options(foo="bar") + eq_(stmt._execution_options, {"foo": "bar"}) s2 = select(table1).select_from(stmt.cte()) eq_(s2._execution_options, {}) compiled = s2.compile() - eq_(compiled.execution_options, {"autocommit": True}) + eq_(compiled.execution_options, {}) def test_embedded_element_true_to_false(self): - stmt = table1.insert() - eq_(stmt._execution_options, {"autocommit": True}) + stmt = table1.insert().execution_options(foo="bar") + eq_(stmt._execution_options, {"foo": "bar"}) s2 = ( - select(table1) - .select_from(stmt.cte()) - .execution_options(autocommit=False) + select(table1).select_from(stmt.cte()).execution_options(foo="bat") ) - eq_(s2._execution_options, {"autocommit": False}) + eq_(s2._execution_options, {"foo": "bat"}) compiled = s2.compile() - eq_(compiled.execution_options, {"autocommit": False}) + eq_(compiled.execution_options, {"foo": "bat"}) class DDLTest(fixtures.TestBase, AssertsCompiledSQL): diff --git a/test/sql/test_cte.py b/test/sql/test_cte.py index 22107eeee..2c8ef83a0 100644 --- a/test/sql/test_cte.py +++ b/test/sql/test_cte.py @@ -1351,8 +1351,6 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL): .cte("t") ) stmt = t.select() - assert "autocommit" not in stmt._execution_options - eq_(stmt.compile().execution_options["autocommit"], True) self.assert_compile( stmt, @@ -1413,9 +1411,6 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL): stmt = select(cte) - assert "autocommit" not in stmt._execution_options - eq_(stmt.compile().execution_options["autocommit"], True) - self.assert_compile( stmt, "WITH pd AS " @@ -1431,10 +1426,8 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL): products = table("products", column("id"), column("price")) cte = products.select().cte("pd") - assert "autocommit" not in cte.select()._execution_options stmt = products.update().where(products.c.price == cte.c.price) - eq_(stmt.compile().execution_options["autocommit"], True) self.assert_compile( stmt, @@ -1455,10 +1448,8 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL): products = table("products", column("id"), column("price")) cte = products.select().cte("pd") - assert "autocommit" not in cte.select()._execution_options stmt = update(cte) - eq_(stmt.compile().execution_options["autocommit"], True) self.assert_compile( stmt, @@ -1477,10 +1468,8 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL): products = table("products", column("id"), column("price")) cte = products.select().cte("pd") - assert "autocommit" not in cte.select()._execution_options stmt = delete(cte) - eq_(stmt.compile().execution_options["autocommit"], True) self.assert_compile( stmt, @@ -1506,7 +1495,6 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL): ) cte = q.cte("deldup") stmt = delete(cte).where(text("RN > 1")) - eq_(stmt.compile().execution_options["autocommit"], True) self.assert_compile( stmt, @@ -2132,10 +2120,6 @@ class NestingCTETest(fixtures.TestBase, AssertsCompiledSQL): stmt = select(cte) - assert "autocommit" not in stmt._execution_options - - eq_(stmt.compile().execution_options["autocommit"], True) - self.assert_compile( stmt, "WITH insert_cte AS " diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py index ef924e068..31cc15155 100644 --- a/test/sql/test_defaults.py +++ b/test/sql/test_defaults.py @@ -841,13 +841,6 @@ class DefaultRoundTripTest(fixtures.TablesTest): eq_(55, row._mapping["col3"]) -class FutureDefaultRoundTripTest( - fixtures.FutureEngineMixin, DefaultRoundTripTest -): - - __backend__ = True - - class CTEDefaultTest(fixtures.TablesTest): __requires__ = ("ctes", "returning", "ctes_on_dml") __backend__ = True diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py index fb3c1165a..22b743434 100644 --- a/test/sql/test_deprecations.py +++ b/test/sql/test_deprecations.py @@ -47,7 +47,6 @@ from sqlalchemy.testing import AssertsCompiledSQL from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures from sqlalchemy.testing import is_ -from sqlalchemy.testing import is_false from sqlalchemy.testing import is_true from sqlalchemy.testing import mock from sqlalchemy.testing.schema import Column @@ -1263,49 +1262,6 @@ class PKIncrementTest(fixtures.TablesTest): ], ) - def test_autoincrement_autocommit(self): - with testing.db.connect() as conn: - with testing.expect_deprecated_20( - "The current statement is being autocommitted using " - "implicit autocommit, " - ): - self._test_autoincrement(conn) - - -class DefaultTest(fixtures.TestBase): - __backend__ = True - - @testing.provide_metadata - def test_close_on_branched(self): - metadata = self.metadata - - def mydefault_using_connection(ctx): - conn = ctx.connection - try: - return conn.execute(select(text("12"))).scalar() - finally: - # ensure a "close()" on this connection does nothing, - # since its a "branched" connection - conn.close() - - table = Table( - "foo", - metadata, - Column("x", Integer), - Column("y", Integer, default=mydefault_using_connection), - ) - - metadata.create_all(testing.db) - with testing.db.connect() as conn: - with testing.expect_deprecated_20( - r"The .close\(\) method on a so-called 'branched' " - r"connection is deprecated as of 1.4, as are " - r"'branched' connections overall" - ): - conn.execute(table.insert().values(x=5)) - - eq_(conn.execute(select(table)).first(), (5, 12)) - class DMLTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): __dialect__ = "default" @@ -1853,95 +1809,6 @@ class DDLDeprecatedBindTest(fixtures.TestBase): if inspect(conn).has_table("foo"): conn.execute(schema.DropTable(table("foo"))) - def test_bind_ddl_deprecated(self, connection): - with testing.expect_deprecated_20( - "The DDL.bind argument is deprecated" - ): - ddl = schema.DDL("create table foo(id integer)", bind=connection) - - with testing.expect_deprecated_20( - r"The DDLElement.execute\(\) method is considered legacy" - ): - ddl.execute() - - def test_bind_create_table_deprecated(self, connection): - t1 = Table("foo", MetaData(), Column("id", Integer)) - - with testing.expect_deprecated_20( - "The CreateTable.bind argument is deprecated" - ): - ddl = schema.CreateTable(t1, bind=connection) - - with testing.expect_deprecated_20( - r"The DDLElement.execute\(\) method is considered legacy" - ): - ddl.execute() - - is_true(inspect(connection).has_table("foo")) - - def test_bind_create_index_deprecated(self, connection): - t1 = Table("foo", MetaData(), Column("id", Integer)) - t1.create(connection) - - idx = schema.Index("foo_idx", t1.c.id) - - with testing.expect_deprecated_20( - "The CreateIndex.bind argument is deprecated" - ): - ddl = schema.CreateIndex(idx, bind=connection) - - with testing.expect_deprecated_20( - r"The DDLElement.execute\(\) method is considered legacy" - ): - ddl.execute() - - is_true( - "foo_idx" - in [ix["name"] for ix in inspect(connection).get_indexes("foo")] - ) - - def test_bind_drop_table_deprecated(self, connection): - t1 = Table("foo", MetaData(), Column("id", Integer)) - - t1.create(connection) - - with testing.expect_deprecated_20( - "The DropTable.bind argument is deprecated" - ): - ddl = schema.DropTable(t1, bind=connection) - - with testing.expect_deprecated_20( - r"The DDLElement.execute\(\) method is considered legacy" - ): - ddl.execute() - - is_false(inspect(connection).has_table("foo")) - - def test_bind_drop_index_deprecated(self, connection): - t1 = Table("foo", MetaData(), Column("id", Integer)) - idx = schema.Index("foo_idx", t1.c.id) - t1.create(connection) - - is_true( - "foo_idx" - in [ix["name"] for ix in inspect(connection).get_indexes("foo")] - ) - - with testing.expect_deprecated_20( - "The DropIndex.bind argument is deprecated" - ): - ddl = schema.DropIndex(idx, bind=connection) - - with testing.expect_deprecated_20( - r"The DDLElement.execute\(\) method is considered legacy" - ): - ddl.execute() - - is_false( - "foo_idx" - in [ix["name"] for ix in inspect(connection).get_indexes("foo")] - ) - @testing.combinations( (schema.AddConstraint,), (schema.DropConstraint,), diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py index 3909fe60d..cdc314e2f 100644 --- a/test/sql/test_resultset.py +++ b/test/sql/test_resultset.py @@ -2228,14 +2228,14 @@ class KeyTargetingTest(fixtures.TablesTest): stmt2 = stmt_fn(self) cache = {} - result = connection._execute_20( + result = connection.execute( stmt1, execution_options={"compiled_cache": cache}, ) result.close() assert cache - result = connection._execute_20( + result = connection.execute( stmt2, execution_options={"compiled_cache": cache}, ) diff --git a/test/sql/test_sequences.py b/test/sql/test_sequences.py index a0fef99be..d6906f9e6 100644 --- a/test/sql/test_sequences.py +++ b/test/sql/test_sequences.py @@ -338,11 +338,6 @@ class SequenceExecTest(fixtures.TestBase): self._assert_seq_result(r.inserted_primary_key[0]) -class FutureSequenceExecTest(fixtures.FutureEngineMixin, SequenceExecTest): - __requires__ = ("sequences",) - __backend__ = True - - class SequenceTest(fixtures.TestBase, testing.AssertsCompiledSQL): __requires__ = ("sequences",) __backend__ = True @@ -502,11 +497,6 @@ class SequenceTest(fixtures.TestBase, testing.AssertsCompiledSQL): assert isinstance(seq.next_value().type, BigInteger) -class FutureSequenceTest(fixtures.FutureEngineMixin, SequenceTest): - __requires__ = ("sequences",) - __backend__ = True - - class TableBoundSequenceTest(fixtures.TablesTest): __requires__ = ("sequences",) __backend__ = True |
