diff options
author | jonathan vanasco <jonathan@2xlp.com> | 2020-10-28 14:35:39 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-10-30 10:02:29 -0400 |
commit | 9ddbd585a62ff1ad56e9ee6fef5898ced1932a88 (patch) | |
tree | a1ba46d4c8fb5981062a22775fa73155532018e6 /lib/sqlalchemy/sql/default_comparator.py | |
parent | 10851b002844fa4f9de7af92dbb15cb1133497eb (diff) | |
download | sqlalchemy-9ddbd585a62ff1ad56e9ee6fef5898ced1932a88.tar.gz |
Apply underscore naming to several more operators
The operator changes are:
* `isfalse` is now `is_false`
* `isnot_distinct_from` is now `is_not_distinct_from`
* `istrue` is now `is_true`
* `notbetween` is now `not_between`
* `notcontains` is now `not_contains`
* `notendswith` is now `not_endswith`
* `notilike` is now `not_ilike`
* `notlike` is now `not_like`
* `notmatch` is now `not_match`
* `notstartswith` is now `not_startswith`
* `nullsfirst` is now `nulls_first`
* `nullslast` is now `nulls_last`
Because these are core operators, the internal migration strategy for this
change is to support legacy terms for an extended period of time -- if not
indefinitely -- but update all documentation, tutorials, and internal usage
to the new terms. The new terms are used to define the functions, and
the legacy terms have been deprecated into aliases of the new terms.
Fixes: #5435
Change-Id: Ifbd7cb1cdda5981990243c4fc4b4ff467dc132ac
Diffstat (limited to 'lib/sqlalchemy/sql/default_comparator.py')
-rw-r--r-- | lib/sqlalchemy/sql/default_comparator.py | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/lib/sqlalchemy/sql/default_comparator.py b/lib/sqlalchemy/sql/default_comparator.py index d5762ff1f..be6d0787b 100644 --- a/lib/sqlalchemy/sql/default_comparator.py +++ b/lib/sqlalchemy/sql/default_comparator.py @@ -57,7 +57,10 @@ def _boolean_compare( negate=negate, modifiers=kwargs, ) - elif op in (operators.is_distinct_from, operators.isnot_distinct_from): + elif op in ( + operators.is_distinct_from, + operators.is_not_distinct_from, + ): return BinaryExpression( expr, coercions.expect(roles.ConstExprRole, obj), @@ -87,7 +90,7 @@ def _boolean_compare( else: raise exc.ArgumentError( "Only '=', '!=', 'is_()', 'is_not()', " - "'is_distinct_from()', 'isnot_distinct_from()' " + "'is_distinct_from()', 'is_not_distinct_from()' " "operators can be used with None/True/False" ) else: @@ -205,7 +208,7 @@ def _match_impl(expr, op, other, **kw): operator=operators.match_op, ), result_type=type_api.MATCHTYPE, - negate=operators.notmatch_op + negate=operators.not_match_op if op is operators.match_op else operators.match_op, **kw @@ -241,7 +244,7 @@ def _between_impl(expr, op, cleft, cright, **kw): group_contents=False, ), op, - negate=operators.notbetween_op + negate=operators.not_between_op if op is operators.between_op else operators.between_op, modifiers=kw, @@ -315,29 +318,29 @@ operator_lookup = { "gt": (_boolean_compare, operators.le), "ge": (_boolean_compare, operators.lt), "eq": (_boolean_compare, operators.ne), - "is_distinct_from": (_boolean_compare, operators.isnot_distinct_from), - "isnot_distinct_from": (_boolean_compare, operators.is_distinct_from), - "like_op": (_boolean_compare, operators.notlike_op), - "ilike_op": (_boolean_compare, operators.notilike_op), - "notlike_op": (_boolean_compare, operators.like_op), - "notilike_op": (_boolean_compare, operators.ilike_op), - "contains_op": (_boolean_compare, operators.notcontains_op), - "startswith_op": (_boolean_compare, operators.notstartswith_op), - "endswith_op": (_boolean_compare, operators.notendswith_op), + "is_distinct_from": (_boolean_compare, operators.is_not_distinct_from), + "is_not_distinct_from": (_boolean_compare, operators.is_distinct_from), + "like_op": (_boolean_compare, operators.not_like_op), + "ilike_op": (_boolean_compare, operators.not_ilike_op), + "not_like_op": (_boolean_compare, operators.like_op), + "not_ilike_op": (_boolean_compare, operators.ilike_op), + "contains_op": (_boolean_compare, operators.not_contains_op), + "startswith_op": (_boolean_compare, operators.not_startswith_op), + "endswith_op": (_boolean_compare, operators.not_endswith_op), "desc_op": (_scalar, UnaryExpression._create_desc), "asc_op": (_scalar, UnaryExpression._create_asc), - "nullsfirst_op": (_scalar, UnaryExpression._create_nullsfirst), - "nullslast_op": (_scalar, UnaryExpression._create_nullslast), + "nulls_first_op": (_scalar, UnaryExpression._create_nulls_first), + "nulls_last_op": (_scalar, UnaryExpression._create_nulls_last), "in_op": (_in_impl, operators.not_in_op), "not_in_op": (_in_impl, operators.in_op), "is_": (_boolean_compare, operators.is_), "is_not": (_boolean_compare, operators.is_not), "collate": (_collate_impl,), "match_op": (_match_impl,), - "notmatch_op": (_match_impl,), + "not_match_op": (_match_impl,), "distinct_op": (_distinct_impl,), "between_op": (_between_impl,), - "notbetween_op": (_between_impl,), + "not_between_op": (_between_impl,), "neg": (_neg_impl,), "getitem": (_getitem_impl,), "lshift": (_unsupported_impl,), |