summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-01-03 13:49:26 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-01-05 19:28:49 -0500
commit01c50c64e302c193733cef7fb146fbab8eaa44bd (patch)
treedca946206da557a14a681768d094b92c95dfabe4 /test/sql
parent146a349d81023805264f81643db50a5281da90da (diff)
downloadsqlalchemy-01c50c64e302c193733cef7fb146fbab8eaa44bd.tar.gz
Remove all remaining removed_in_20 warnings slated for removal
Finalize all remaining removed-in-2.0 changes so that we can begin doing pep-484 typing without old things getting in the way (we will also have to do public_factory). note there are a few "moved_in_20()" and "became_legacy_in_20()" warnings still in place. The SQLALCHEMY_WARN_20 variable is now removed. Also removed here are the legacy "in place mutators" for Select statements, and some keyword-only argument signatures in Core have been added. Also in the big change department, the ORM mapper() function is removed entirely; the Mapper class is otherwise unchanged, just the public-facing API function. Mappers are now always given a registry in which to participate, however the argument signature of Mapper is not changed. ideally "registry" would be the first positional argument. Fixes: #7257 Change-Id: Ic70c57b9f1cf7eb996338af5183b11bdeb3e1623
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_case_statement.py17
-rw-r--r--test/sql/test_deprecations.py669
-rw-r--r--test/sql/test_roles.py14
-rw-r--r--test/sql/test_selectable.py11
-rw-r--r--test/sql/test_types.py7
5 files changed, 19 insertions, 699 deletions
diff --git a/test/sql/test_case_statement.py b/test/sql/test_case_statement.py
index db7f16194..6893a9442 100644
--- a/test/sql/test_case_statement.py
+++ b/test/sql/test_case_statement.py
@@ -215,23 +215,10 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL):
def test_when_dicts(self, test_case, expected):
t = table("test", column("col1"))
- whens, value, else_ = testing.resolve_lambda(test_case, t=t)
-
- def _case_args(whens, value=None, else_=None):
- kw = {}
- if value is not None:
- kw["value"] = value
- if else_ is not None:
- kw["else_"] = else_
-
- return case(whens, **kw)
-
- # note: 1.3 also does not allow this form
- # case([whens], **kw)
+ when_dict, value, else_ = testing.resolve_lambda(test_case, t=t)
self.assert_compile(
- _case_args(whens=whens, value=value, else_=else_),
- expected,
+ case(when_dict, value=value, else_=else_), expected
)
def test_text_doesnt_explode(self, connection):
diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py
index ea075b36d..f07410110 100644
--- a/test/sql/test_deprecations.py
+++ b/test/sql/test_deprecations.py
@@ -1,12 +1,8 @@
#! coding: utf-8
-import itertools
-import random
-
from sqlalchemy import alias
from sqlalchemy import and_
from sqlalchemy import bindparam
-from sqlalchemy import case
from sqlalchemy import CHAR
from sqlalchemy import column
from sqlalchemy import exc
@@ -29,14 +25,11 @@ from sqlalchemy import text
from sqlalchemy.engine import default
from sqlalchemy.sql import coercions
from sqlalchemy.sql import LABEL_STYLE_TABLENAME_PLUS_COL
-from sqlalchemy.sql import literal
from sqlalchemy.sql import operators
from sqlalchemy.sql import quoted_name
from sqlalchemy.sql import roles
-from sqlalchemy.sql import update
from sqlalchemy.sql import visitors
from sqlalchemy.sql.selectable import SelectStatementGrouping
-from sqlalchemy.testing import assert_raises_message
from sqlalchemy.testing import assertions
from sqlalchemy.testing import AssertsCompiledSQL
from sqlalchemy.testing import eq_
@@ -46,7 +39,6 @@ from sqlalchemy.testing import is_true
from sqlalchemy.testing import mock
from sqlalchemy.testing.schema import Column
from sqlalchemy.testing.schema import Table
-from .test_update import _UpdateFromTestBase
class ToMetaDataTest(fixtures.TestBase):
@@ -313,165 +305,6 @@ class SelectableTest(fixtures.TestBase, AssertsCompiledSQL):
):
eq_(stmt.froms, [t1])
- def test_case_list_legacy(self):
- t1 = table("t", column("q"))
-
- with testing.expect_deprecated(
- r"The \"whens\" argument to case\(\), when referring "
- r"to a sequence of items, is now passed"
- ):
- stmt = select(t1).where(
- case(
- [(t1.c.q == 5, "foo"), (t1.c.q == 10, "bar")], else_="bat"
- )
- != "bat"
- )
-
- self.assert_compile(
- stmt,
- "SELECT t.q FROM t WHERE CASE WHEN (t.q = :q_1) "
- "THEN :param_1 WHEN (t.q = :q_2) THEN :param_2 "
- "ELSE :param_3 END != :param_4",
- )
-
- def test_case_whens_kw(self):
- t1 = table("t", column("q"))
-
- with testing.expect_deprecated(
- r"The \"whens\" argument to case\(\), when referring "
- "to a sequence of items, is now passed"
- ):
- stmt = select(t1).where(
- case(
- whens=[(t1.c.q == 5, "foo"), (t1.c.q == 10, "bar")],
- else_="bat",
- )
- != "bat"
- )
-
- self.assert_compile(
- stmt,
- "SELECT t.q FROM t WHERE CASE WHEN (t.q = :q_1) "
- "THEN :param_1 WHEN (t.q = :q_2) THEN :param_2 "
- "ELSE :param_3 END != :param_4",
- )
-
- @testing.combinations(
- (
- (lambda t: ({"x": "y"}, t.c.col1, None)),
- "CASE test.col1 WHEN :param_1 THEN :param_2 END",
- ),
- (
- (lambda t: ({"x": "y", "p": "q"}, t.c.col1, None)),
- "CASE test.col1 WHEN :param_1 THEN :param_2 "
- "WHEN :param_3 THEN :param_4 END",
- ),
- (
- (lambda t: ({t.c.col1 == 7: "x"}, None, 10)),
- "CASE WHEN (test.col1 = :col1_1) THEN :param_1 ELSE :param_2 END",
- ),
- (
- (lambda t: ({t.c.col1 == 7: "x", t.c.col1 == 10: "y"}, None, 10)),
- "CASE WHEN (test.col1 = :col1_1) THEN :param_1 "
- "WHEN (test.col1 = :col1_2) THEN :param_2 ELSE :param_3 END",
- ),
- argnames="test_case, expected",
- )
- def test_when_kwarg(self, test_case, expected):
- t = table("test", column("col1"))
-
- whens, value, else_ = testing.resolve_lambda(test_case, t=t)
-
- def _case_args(whens, value=None, else_=None):
- kw = {}
- if value is not None:
- kw["value"] = value
- if else_ is not None:
- kw["else_"] = else_
-
- with testing.expect_deprecated_20(
- r'The "whens" argument to case\(\) is now passed using '
- r"positional style only, not as a keyword argument."
- ):
-
- return case(whens=whens, **kw)
-
- # note: 1.3 also does not allow this form
- # case([whens], **kw)
-
- self.assert_compile(
- _case_args(whens=whens, value=value, else_=else_),
- expected,
- )
-
- def test_case_whens_dict_kw(self):
- t1 = table("t", column("q"))
- with testing.expect_deprecated(
- r"The \"whens\" argument to case\(\) is now passed"
- ):
- stmt = select(t1).where(
- case(
- whens={t1.c.q == 5: "foo"},
- else_="bat",
- )
- != "bat"
- )
- self.assert_compile(
- stmt,
- "SELECT t.q FROM t WHERE CASE WHEN (t.q = :q_1) THEN "
- ":param_1 ELSE :param_2 END != :param_3",
- )
-
- def test_case_kw_arg_detection(self):
- # because we support py2k, case() has to parse **kw for now
-
- assert_raises_message(
- TypeError,
- "unknown arguments: bat, foo",
- case,
- (column("x") == 10, 5),
- else_=15,
- foo="bar",
- bat="hoho",
- )
-
- def test_with_only_generative(self):
- table1 = table(
- "table1",
- column("col1"),
- column("col2"),
- column("col3"),
- column("colx"),
- )
- s1 = table1.select().scalar_subquery()
-
- with testing.expect_deprecated_20(
- r"The \"columns\" argument to "
- r"Select.with_only_columns\(\), when referring "
- "to a sequence of items, is now passed"
- ):
- stmt = s1.with_only_columns([s1])
- self.assert_compile(
- stmt,
- "SELECT (SELECT table1.col1, table1.col2, "
- "table1.col3, table1.colx FROM table1) AS anon_1",
- )
-
- def test_from_list_with_columns(self):
- table1 = table("t1", column("a"))
- table2 = table("t2", column("b"))
- s1 = select(table1.c.a, table2.c.b)
- self.assert_compile(s1, "SELECT t1.a, t2.b FROM t1, t2")
-
- with testing.expect_deprecated_20(
- r"The \"columns\" argument to "
- r"Select.with_only_columns\(\), when referring "
- "to a sequence of items, is now passed"
- ):
- s2 = s1.with_only_columns([table2.c.b])
-
- self.assert_compile(s2, "SELECT t2.b FROM t2")
-
def test_column(self):
stmt = select(column("x"))
with testing.expect_deprecated(
@@ -504,16 +337,6 @@ class SelectableTest(fixtures.TestBase, AssertsCompiledSQL):
"ON basefrom.a = joinfrom.a",
)
- with testing.expect_deprecated(r"The Select.append_column\(\)"):
- replaced.append_column(joinfrom.c.b)
-
- self.assert_compile(
- replaced,
- "SELECT basefrom.a, joinfrom.b FROM (SELECT 1 AS a) AS basefrom "
- "JOIN (SELECT 1 AS a, 2 AS b) AS joinfrom "
- "ON basefrom.a = joinfrom.a",
- )
-
def test_against_cloned_non_table(self):
# test that corresponding column digs across
# clone boundaries with anonymous labeled elements
@@ -567,31 +390,6 @@ class SelectableTest(fixtures.TestBase, AssertsCompiledSQL):
assert u.corresponding_column(s2.c.table2_coly) is u.c.coly
assert s2.c.corresponding_column(u.c.coly) is s2.c.table2_coly
- def test_join_alias(self):
- j1 = self.table1.join(self.table2)
-
- with testing.expect_deprecated_20(
- r"The Join.alias\(\) method is considered legacy"
- ):
- self.assert_compile(
- j1.alias(),
- "SELECT table1.col1 AS table1_col1, table1.col2 AS "
- "table1_col2, table1.col3 AS table1_col3, table1.colx "
- "AS table1_colx, table2.col1 AS table2_col1, "
- "table2.col2 AS table2_col2, table2.col3 AS table2_col3, "
- "table2.coly AS table2_coly FROM table1 JOIN table2 "
- "ON table1.col1 = table2.col2",
- )
-
- with testing.expect_deprecated_20(
- r"The Join.alias\(\) method is considered legacy"
- ):
- self.assert_compile(
- j1.alias(flat=True),
- "table1 AS table1_1 JOIN table2 AS table2_1 "
- "ON table1_1.col1 = table2_1.col2",
- )
-
def test_join_against_self_implicit_subquery(self):
jj = select(self.table1.c.col1.label("bar_col1"))
with testing.expect_deprecated(
@@ -613,16 +411,6 @@ class SelectableTest(fixtures.TestBase, AssertsCompiledSQL):
):
assert jjj.corresponding_column(jj.c.bar_col1) is jjj_bar_col1
- # test alias of the join
-
- with testing.expect_deprecated(
- r"The Join.alias\(\) method is considered legacy"
- ):
- j2 = jjj.alias("foo")
- assert (
- j2.corresponding_column(self.table1.c.col1) is j2.c.table1_col1
- )
-
def test_select_labels(self):
a = self.table1.select().set_label_style(
LABEL_STYLE_TABLENAME_PLUS_COL
@@ -759,104 +547,6 @@ class TextualSelectTest(fixtures.TestBase, AssertsCompiledSQL):
eq_(t.c.c.type._type_affinity, String)
-class DeprecatedAppendMethTest(fixtures.TestBase, AssertsCompiledSQL):
- __dialect__ = "default"
-
- def _expect_deprecated(self, clsname, methname, newmeth):
- return testing.expect_deprecated(
- r"The %s.append_%s\(\) method is deprecated "
- r"and will be removed in a future release. Use the generative "
- r"method %s.%s\(\)." % (clsname, methname, clsname, newmeth)
- )
-
- def test_append_whereclause(self):
- t = table("t", column("q"))
- stmt = select(t)
-
- with self._expect_deprecated("Select", "whereclause", "where"):
- stmt.append_whereclause(t.c.q == 5)
-
- self.assert_compile(stmt, "SELECT t.q FROM t WHERE t.q = :q_1")
-
- def test_append_having(self):
- t = table("t", column("q"))
- stmt = select(t).group_by(t.c.q)
-
- with self._expect_deprecated("Select", "having", "having"):
- stmt.append_having(t.c.q == 5)
-
- self.assert_compile(
- stmt, "SELECT t.q FROM t GROUP BY t.q HAVING t.q = :q_1"
- )
-
- def test_append_order_by(self):
- t = table("t", column("q"), column("x"))
- stmt = select(t).where(t.c.q == 5)
-
- with self._expect_deprecated(
- "GenerativeSelect", "order_by", "order_by"
- ):
- stmt.append_order_by(t.c.x)
-
- self.assert_compile(
- stmt, "SELECT t.q, t.x FROM t WHERE t.q = :q_1 ORDER BY t.x"
- )
-
- def test_append_group_by(self):
- t = table("t", column("q"))
- stmt = select(t)
-
- with self._expect_deprecated(
- "GenerativeSelect", "group_by", "group_by"
- ):
- stmt.append_group_by(t.c.q)
-
- stmt = stmt.having(t.c.q == 5)
-
- self.assert_compile(
- stmt, "SELECT t.q FROM t GROUP BY t.q HAVING t.q = :q_1"
- )
-
- def test_append_correlation(self):
- t1 = table("t1", column("q"))
- t2 = table("t2", column("q"), column("p"))
-
- inner = select(t2.c.p).where(t2.c.q == t1.c.q)
-
- with self._expect_deprecated("Select", "correlation", "correlate"):
- inner.append_correlation(t1)
- stmt = select(t1).where(t1.c.q == inner.scalar_subquery())
-
- self.assert_compile(
- stmt,
- "SELECT t1.q FROM t1 WHERE t1.q = "
- "(SELECT t2.p FROM t2 WHERE t2.q = t1.q)",
- )
-
- def test_append_column(self):
- t1 = table("t1", column("q"), column("p"))
- stmt = select(t1.c.q)
- with self._expect_deprecated("Select", "column", "add_columns"):
- stmt.append_column(t1.c.p)
- self.assert_compile(stmt, "SELECT t1.q, t1.p FROM t1")
-
- def test_append_prefix(self):
- t1 = table("t1", column("q"), column("p"))
- stmt = select(t1.c.q)
- with self._expect_deprecated("Select", "prefix", "prefix_with"):
- stmt.append_prefix("FOO BAR")
- self.assert_compile(stmt, "SELECT FOO BAR t1.q FROM t1")
-
- def test_append_from(self):
- t1 = table("t1", column("q"))
- t2 = table("t2", column("q"))
-
- stmt = select(t1)
- with self._expect_deprecated("Select", "from", "select_from"):
- stmt.append_from(t1.join(t2, t1.c.q == t2.c.q))
- self.assert_compile(stmt, "SELECT t1.q FROM t1 JOIN t2 ON t1.q = t2.q")
-
-
class KeyTargetingTest(fixtures.TablesTest):
run_inserts = "once"
run_deletes = None
@@ -971,365 +661,6 @@ class PKIncrementTest(fixtures.TablesTest):
)
-class DMLTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL):
- __dialect__ = "default"
-
- def test_insert_inline_kw_defaults(self):
- m = MetaData()
- foo = Table("foo", m, Column("id", Integer))
-
- t = Table(
- "test",
- m,
- Column("col1", Integer, default=func.foo(1)),
- Column(
- "col2",
- Integer,
- default=select(func.coalesce(func.max(foo.c.id))),
- ),
- )
-
- with testing.expect_deprecated_20(
- "The insert.inline parameter will be removed in SQLAlchemy 2.0."
- ):
- stmt = t.insert(inline=True, values={})
-
- self.assert_compile(
- stmt,
- "INSERT INTO test (col1, col2) VALUES (foo(:foo_1), "
- "(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM "
- "foo))",
- )
-
- def test_insert_inline_kw_default(self):
- metadata = MetaData()
- table = Table(
- "sometable",
- metadata,
- Column("id", Integer, primary_key=True),
- Column("foo", Integer, default=func.foobar()),
- )
-
- with testing.expect_deprecated_20(
- "The insert.inline parameter will be removed in SQLAlchemy 2.0."
- ):
- stmt = table.insert(values={}, inline=True)
-
- self.assert_compile(
- stmt,
- "INSERT INTO sometable (foo) VALUES (foobar())",
- )
-
- with testing.expect_deprecated_20(
- "The insert.inline parameter will be removed in SQLAlchemy 2.0."
- ):
- stmt = table.insert(inline=True)
-
- self.assert_compile(
- stmt,
- "INSERT INTO sometable (foo) VALUES (foobar())",
- params={},
- )
-
- def test_update_inline_kw_defaults(self):
- m = MetaData()
- foo = Table("foo", m, Column("id", Integer))
-
- t = Table(
- "test",
- m,
- Column("col1", Integer, onupdate=func.foo(1)),
- Column(
- "col2",
- Integer,
- onupdate=select(func.coalesce(func.max(foo.c.id))),
- ),
- Column("col3", String(30)),
- )
-
- with testing.expect_deprecated_20(
- "The update.inline parameter will be removed in SQLAlchemy 2.0."
- ):
- stmt = t.update(inline=True, values={"col3": "foo"})
-
- self.assert_compile(
- stmt,
- "UPDATE test SET col1=foo(:foo_1), col2=(SELECT "
- "coalesce(max(foo.id)) AS coalesce_1 FROM foo), "
- "col3=:col3",
- )
-
- def test_update_dialect_kwargs(self):
- t = table("foo", column("bar"))
-
- with testing.expect_deprecated_20("Passing dialect keyword arguments"):
- stmt = t.update(mysql_limit=10)
-
- self.assert_compile(
- stmt, "UPDATE foo SET bar=%s LIMIT 10", dialect="mysql"
- )
-
- def test_update_whereclause(self):
- table1 = table(
- "mytable",
- Column("myid", Integer),
- Column("name", String(30)),
- )
-
- with testing.expect_deprecated_20(
- "The update.whereclause parameter will be "
- "removed in SQLAlchemy 2.0"
- ):
- self.assert_compile(
- table1.update(table1.c.myid == 7),
- "UPDATE mytable SET myid=:myid, name=:name "
- "WHERE mytable.myid = :myid_1",
- )
-
- def test_update_values(self):
- table1 = table(
- "mytable",
- Column("myid", Integer),
- Column("name", String(30)),
- )
-
- with testing.expect_deprecated_20(
- "The update.values parameter will be removed in SQLAlchemy 2.0"
- ):
- self.assert_compile(
- table1.update(values={table1.c.myid: 7}),
- "UPDATE mytable SET myid=:myid",
- )
-
- def test_delete_whereclause(self):
- table1 = table(
- "mytable",
- Column("myid", Integer),
- )
-
- with testing.expect_deprecated_20(
- "The delete.whereclause parameter will be "
- "removed in SQLAlchemy 2.0"
- ):
- self.assert_compile(
- table1.delete(table1.c.myid == 7),
- "DELETE FROM mytable WHERE mytable.myid = :myid_1",
- )
-
- def test_update_ordered_parameters_fire_onupdate(self):
- table = self.tables.update_w_default
-
- values = [(table.c.y, table.c.x + 5), ("x", 10)]
-
- with testing.expect_deprecated_20(
- "The update.preserve_parameter_order parameter will be "
- "removed in SQLAlchemy 2.0."
- ):
- self.assert_compile(
- table.update(preserve_parameter_order=True).values(values),
- "UPDATE update_w_default "
- "SET ycol=(update_w_default.x + :x_1), "
- "x=:x, data=:data",
- )
-
- def test_update_ordered_parameters_override_onupdate(self):
- table = self.tables.update_w_default
-
- values = [
- (table.c.y, table.c.x + 5),
- (table.c.data, table.c.x + 10),
- ("x", 10),
- ]
-
- with testing.expect_deprecated_20(
- "The update.preserve_parameter_order parameter will be "
- "removed in SQLAlchemy 2.0."
- ):
- self.assert_compile(
- table.update(preserve_parameter_order=True).values(values),
- "UPDATE update_w_default "
- "SET ycol=(update_w_default.x + :x_1), "
- "data=(update_w_default.x + :x_2), x=:x",
- )
-
- def test_update_ordered_parameters_oldstyle_1(self):
- table1 = self.tables.mytable
-
- # Confirm that we can pass values as list value pairs
- # note these are ordered *differently* from table.c
- values = [
- (table1.c.name, table1.c.name + "lala"),
- (table1.c.myid, func.do_stuff(table1.c.myid, literal("hoho"))),
- ]
-
- with testing.expect_deprecated_20(
- "The update.preserve_parameter_order parameter will be "
- "removed in SQLAlchemy 2.0.",
- "The update.whereclause parameter will be "
- "removed in SQLAlchemy 2.0",
- "The update.values parameter will be removed in SQLAlchemy 2.0",
- ):
- self.assert_compile(
- update(
- table1,
- (table1.c.myid == func.hoho(4))
- & (
- table1.c.name
- == literal("foo") + table1.c.name + literal("lala")
- ),
- preserve_parameter_order=True,
- values=values,
- ),
- "UPDATE mytable "
- "SET "
- "name=(mytable.name || :name_1), "
- "myid=do_stuff(mytable.myid, :param_1) "
- "WHERE "
- "mytable.myid = hoho(:hoho_1) AND "
- "mytable.name = :param_2 || mytable.name || :param_3",
- )
-
- def test_update_ordered_parameters_oldstyle_2(self):
- table1 = self.tables.mytable
-
- # Confirm that we can pass values as list value pairs
- # note these are ordered *differently* from table.c
- values = [
- (table1.c.name, table1.c.name + "lala"),
- ("description", "some desc"),
- (table1.c.myid, func.do_stuff(table1.c.myid, literal("hoho"))),
- ]
-
- with testing.expect_deprecated_20(
- "The update.preserve_parameter_order parameter will be "
- "removed in SQLAlchemy 2.0.",
- "The update.whereclause parameter will be "
- "removed in SQLAlchemy 2.0",
- ):
- self.assert_compile(
- update(
- table1,
- (table1.c.myid == func.hoho(4))
- & (
- table1.c.name
- == literal("foo") + table1.c.name + literal("lala")
- ),
- preserve_parameter_order=True,
- ).values(values),
- "UPDATE mytable "
- "SET "
- "name=(mytable.name || :name_1), "
- "description=:description, "
- "myid=do_stuff(mytable.myid, :param_1) "
- "WHERE "
- "mytable.myid = hoho(:hoho_1) AND "
- "mytable.name = :param_2 || mytable.name || :param_3",
- )
-
- def test_update_preserve_order_reqs_listtups(self):
- table1 = self.tables.mytable
-
- with testing.expect_deprecated_20(
- "The update.preserve_parameter_order parameter will be "
- "removed in SQLAlchemy 2.0."
- ):
- testing.assert_raises_message(
- ValueError,
- r"When preserve_parameter_order is True, values\(\) "
- r"only accepts a list of 2-tuples",
- table1.update(preserve_parameter_order=True).values,
- {"description": "foo", "name": "bar"},
- )
-
- @testing.fixture
- def randomized_param_order_update(self):
- from sqlalchemy.sql.dml import UpdateDMLState
-
- super_process_ordered_values = UpdateDMLState._process_ordered_values
-
- # this fixture is needed for Python 3.6 and above to work around
- # dictionaries being insert-ordered. in python 2.7 the previous
- # logic fails pretty easily without this fixture.
- def _process_ordered_values(self, statement):
- super_process_ordered_values(self, statement)
-
- tuples = list(self._dict_parameters.items())
- random.shuffle(tuples)
- self._dict_parameters = dict(tuples)
-
- dialect = default.StrCompileDialect()
- dialect.paramstyle = "qmark"
- dialect.positional = True
-
- with mock.patch.object(
- UpdateDMLState, "_process_ordered_values", _process_ordered_values
- ):
- yield
-
- def random_update_order_parameters():
- from sqlalchemy import ARRAY
-
- t = table(
- "foo",
- column("data1", ARRAY(Integer)),
- column("data2", ARRAY(Integer)),
- column("data3", ARRAY(Integer)),
- column("data4", ARRAY(Integer)),
- )
-
- idx_to_value = [
- (t.c.data1, 5, 7),
- (t.c.data2, 10, 18),
- (t.c.data3, 8, 4),
- (t.c.data4, 12, 14),
- ]
-
- def combinations():
- while True:
- random.shuffle(idx_to_value)
- yield list(idx_to_value)
-
- return testing.combinations(
- *[
- (t, combination)
- for i, combination in zip(range(10), combinations())
- ],
- argnames="t, idx_to_value",
- )
-
- @random_update_order_parameters()
- def test_update_to_expression_ppo(
- self, randomized_param_order_update, t, idx_to_value
- ):
- dialect = default.StrCompileDialect()
- dialect.paramstyle = "qmark"
- dialect.positional = True
-
- with testing.expect_deprecated_20(
- "The update.preserve_parameter_order parameter will be "
- "removed in SQLAlchemy 2.0."
- ):
- stmt = t.update(preserve_parameter_order=True).values(
- [(col[idx], val) for col, idx, val in idx_to_value]
- )
-
- self.assert_compile(
- stmt,
- "UPDATE foo SET %s"
- % (
- ", ".join(
- "%s[?]=?" % col.key for col, idx, val in idx_to_value
- )
- ),
- dialect=dialect,
- checkpositional=tuple(
- itertools.chain.from_iterable(
- (idx, val) for col, idx, val in idx_to_value
- )
- ),
- )
-
-
class TableDeprecationTest(fixtures.TestBase):
def test_mustexists(self):
with testing.expect_deprecated("Deprecated alias of .*must_exist"):
diff --git a/test/sql/test_roles.py b/test/sql/test_roles.py
index abbef8e28..5c9ed3588 100644
--- a/test/sql/test_roles.py
+++ b/test/sql/test_roles.py
@@ -226,15 +226,13 @@ class RoleTest(fixtures.TestBase):
):
expect(roles.ExpressionElementRole, Thing())
- def test_statement_text_coercion(self):
- with testing.expect_deprecated_20(
- "Using plain strings to indicate SQL statements"
+ def test_no_statement_text_coercion(self):
+ with testing.expect_raises_message(
+ exc.ArgumentError,
+ r"Textual SQL expression 'select \* from table' should be "
+ "explicitly declared",
):
- is_true(
- expect(roles.StatementRole, "select * from table").compare(
- text("select * from table")
- )
- )
+ expect(roles.StatementRole, "select * from table")
def test_select_statement_no_text_coercion(self):
assert_raises_message(
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index c3a2d8d3c..a63ae5be4 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -608,6 +608,17 @@ class SelectableTest(
"table1.col3, table1.colx FROM table1) AS anon_1",
)
+ def test_with_only_generative_no_list(self):
+ s1 = table1.select().scalar_subquery()
+
+ with testing.expect_raises_message(
+ exc.ArgumentError,
+ r"The \"columns\" argument to "
+ r"Select.with_only_columns\(\), when referring "
+ "to a sequence of items, is now passed",
+ ):
+ s1.with_only_columns([s1])
+
@testing.combinations(
(
[table1.c.col1],
diff --git a/test/sql/test_types.py b/test/sql/test_types.py
index fb1bdad2e..79b77581d 100644
--- a/test/sql/test_types.py
+++ b/test/sql/test_types.py
@@ -79,7 +79,6 @@ from sqlalchemy.testing import AssertsCompiledSQL
from sqlalchemy.testing import AssertsExecutionResults
from sqlalchemy.testing import engines
from sqlalchemy.testing import eq_
-from sqlalchemy.testing import expect_deprecated_20
from sqlalchemy.testing import expect_raises
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
@@ -2529,12 +2528,6 @@ class EnumTest(AssertsCompiledSQL, fixtures.TablesTest):
[(1, self.SomeEnum.three), (2, self.SomeEnum.three)],
)
- def test_omit_warn(self):
- with expect_deprecated_20(
- r"The provided enum someenum contains the aliases \['four'\]"
- ):
- Enum(self.SomeEnum)
-
@testing.combinations(
(True, "native"), (False, "non_native"), id_="ai", argnames="native"
)