diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-07-20 11:03:08 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-07-21 16:00:12 -0400 |
| commit | 27ec4929198807702190b96d3c00d0291976f49e (patch) | |
| tree | 210716d7c12dcd4e3c17376730e4e6b2794fc792 /lib/sqlalchemy/sql | |
| parent | e72106d1499ec628487f7e428e7c49acdd4eb9c0 (diff) | |
| download | sqlalchemy-27ec4929198807702190b96d3c00d0291976f49e.tar.gz | |
dont warn for dictionary passed positionally
Fixed issue where use of the :paramref:`_sql.case.whens` parameter passing
a dictionary positionally and not as a keyword argument would emit a 2.0
deprecation warning, referring to the deprecation of passing a list
positionally. The dictionary format of "whens", passed positionally, is
still supported and was accidentally marked as deprecated.
Removes warning filter for case statement.
Fixes: #6786
Change-Id: I8efd1882563773bec89ae5e34f0dfede77fc4683
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/coercions.py | 11 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/elements.py | 16 |
2 files changed, 14 insertions, 13 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 e253ddb93..ae93eb2a6 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: |
