diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2021-07-21 21:22:46 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-07-21 21:22:46 +0000 |
| commit | 79a27c9fcb1ba4909834a7e2d51c29afb0688cd5 (patch) | |
| tree | b8565e729047fc9adce22a9f434aa6dd95399405 /lib/sqlalchemy | |
| parent | a34a4af8a80f4edd12b022753b69065025818e20 (diff) | |
| parent | 27ec4929198807702190b96d3c00d0291976f49e (diff) | |
| download | sqlalchemy-79a27c9fcb1ba4909834a7e2d51c29afb0688cd5.tar.gz | |
Merge "dont warn for dictionary passed positionally"
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/sql/coercions.py | 11 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/elements.py | 16 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/suite/test_select.py | 20 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/suite/test_types.py | 10 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/warnings.py | 1 |
5 files changed, 26 insertions, 32 deletions
diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py index e21f4a9a5..dce329352 100644 --- a/lib/sqlalchemy/sql/coercions.py +++ b/lib/sqlalchemy/sql/coercions.py @@ -97,11 +97,12 @@ def _document_text_coercion(paramname, meth_rst, param_rst): def _expression_collection_was_a_list(attrname, fnname, args): if args and isinstance(args[0], (list, set, dict)) and len(args) == 1: - util.warn_deprecated_20( - 'The "%s" argument to %s() is now passed as a series of ' - "positional " - "elements, rather than as a list. " % (attrname, fnname) - ) + if isinstance(args[0], list): + util.warn_deprecated_20( + 'The "%s" argument to %s(), when referring to a sequence ' + "of items, is now passed as a series of positional " + "elements, rather than as a list. " % (attrname, fnname) + ) return args[0] else: return args diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index f519c1b3e..58db56a9c 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -2918,15 +2918,15 @@ class Case(ColumnElement): if "whens" in kw: util.warn_deprecated_20( - 'The "whens" argument to case() is now passed as a series of ' - "positional " - "elements, rather than as a list. " - ) - whens = kw.pop("whens") - else: - whens = coercions._expression_collection_was_a_list( - "whens", "case", whens + 'The "whens" argument to case() is now passed using ' + "positional style only, not as a keyword argument." ) + whens = (kw.pop("whens"),) + + whens = coercions._expression_collection_was_a_list( + "whens", "case", whens + ) + try: whens = util.dictlike_iteritems(whens) except TypeError: diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py index 0a1227e58..c96c62a45 100644 --- a/lib/sqlalchemy/testing/suite/test_select.py +++ b/lib/sqlalchemy/testing/suite/test_select.py @@ -1259,12 +1259,10 @@ class ExpandingBoundInTest(fixtures.TablesTest): def test_null_in_empty_set_is_false_bindparam(self, connection): stmt = select( case( - [ - ( - null().in_(bindparam("foo", value=())), - true(), - ) - ], + ( + null().in_(bindparam("foo", value=())), + true(), + ), else_=false(), ) ) @@ -1273,12 +1271,10 @@ class ExpandingBoundInTest(fixtures.TablesTest): def test_null_in_empty_set_is_false_direct(self, connection): stmt = select( case( - [ - ( - null().in_([]), - true(), - ) - ], + ( + null().in_([]), + true(), + ), else_=false(), ) ) diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index f793ff529..d367e7dc3 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -362,12 +362,10 @@ class _DateFixture(_LiteralRoundTripFixture, fixtures.TestBase): id_ = result.inserted_primary_key[0] stmt = select(date_table.c.id).where( case( - [ - ( - bindparam("foo", type_=self.datatype) != None, - bindparam("foo", type_=self.datatype), - ) - ], + ( + bindparam("foo", type_=self.datatype) != None, + bindparam("foo", type_=self.datatype), + ), else_=date_table.c.date_data, ) == date_table.c.date_data diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py index f8d6296a0..af5ad184f 100644 --- a/lib/sqlalchemy/testing/warnings.py +++ b/lib/sqlalchemy/testing/warnings.py @@ -74,7 +74,6 @@ def setup_filters(): "arguments in version 2.0", r"The Join.select\(\) method will no longer accept keyword arguments " "in version 2.0.", - r"The \"whens\" argument to case\(\) is now passed", r"The Join.select\(\).whereclause parameter is deprecated", # # DML |
