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/compiler.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/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 10499975c..23c9d5c0a 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -185,10 +185,10 @@ OPERATORS = { operators.ge: " >= ", operators.eq: " = ", operators.is_distinct_from: " IS DISTINCT FROM ", - operators.isnot_distinct_from: " IS NOT DISTINCT FROM ", + operators.is_not_distinct_from: " IS NOT DISTINCT FROM ", operators.concat_op: " || ", operators.match_op: " MATCH ", - operators.notmatch_op: " NOT MATCH ", + operators.not_match_op: " NOT MATCH ", operators.in_op: " IN ", operators.not_in_op: " NOT IN ", operators.comma_op: ", ", @@ -206,8 +206,8 @@ OPERATORS = { # modifiers operators.desc_op: " DESC", operators.asc_op: " ASC", - operators.nullsfirst_op: " NULLS FIRST", - operators.nullslast_op: " NULLS LAST", + operators.nulls_first_op: " NULLS FIRST", + operators.nulls_last_op: " NULLS LAST", } FUNCTIONS = { @@ -1860,7 +1860,7 @@ class SQLCompiler(Compiled): "Unary expression has no operator or modifier" ) - def visit_istrue_unary_operator(self, element, operator, **kw): + def visit_is_true_unary_operator(self, element, operator, **kw): if ( element._is_implicitly_boolean or self.dialect.supports_native_boolean @@ -1869,7 +1869,7 @@ class SQLCompiler(Compiled): else: return "%s = 1" % self.process(element.element, **kw) - def visit_isfalse_unary_operator(self, element, operator, **kw): + def visit_is_false_unary_operator(self, element, operator, **kw): if ( element._is_implicitly_boolean or self.dialect.supports_native_boolean @@ -1878,7 +1878,7 @@ class SQLCompiler(Compiled): else: return "%s = 0" % self.process(element.element, **kw) - def visit_notmatch_op_binary(self, binary, operator, **kw): + def visit_not_match_op_binary(self, binary, operator, **kw): return "NOT %s" % self.visit_binary( binary, override_operator=operators.match_op ) @@ -2083,11 +2083,11 @@ class SQLCompiler(Compiled): binary.right = percent.__add__(binary.right).__add__(percent) return self.visit_like_op_binary(binary, operator, **kw) - def visit_notcontains_op_binary(self, binary, operator, **kw): + def visit_not_contains_op_binary(self, binary, operator, **kw): binary = binary._clone() percent = self._like_percent_literal binary.right = percent.__add__(binary.right).__add__(percent) - return self.visit_notlike_op_binary(binary, operator, **kw) + return self.visit_not_like_op_binary(binary, operator, **kw) def visit_startswith_op_binary(self, binary, operator, **kw): binary = binary._clone() @@ -2095,11 +2095,11 @@ class SQLCompiler(Compiled): binary.right = percent.__radd__(binary.right) return self.visit_like_op_binary(binary, operator, **kw) - def visit_notstartswith_op_binary(self, binary, operator, **kw): + def visit_not_startswith_op_binary(self, binary, operator, **kw): binary = binary._clone() percent = self._like_percent_literal binary.right = percent.__radd__(binary.right) - return self.visit_notlike_op_binary(binary, operator, **kw) + return self.visit_not_like_op_binary(binary, operator, **kw) def visit_endswith_op_binary(self, binary, operator, **kw): binary = binary._clone() @@ -2107,11 +2107,11 @@ class SQLCompiler(Compiled): binary.right = percent.__add__(binary.right) return self.visit_like_op_binary(binary, operator, **kw) - def visit_notendswith_op_binary(self, binary, operator, **kw): + def visit_not_endswith_op_binary(self, binary, operator, **kw): binary = binary._clone() percent = self._like_percent_literal binary.right = percent.__add__(binary.right) - return self.visit_notlike_op_binary(binary, operator, **kw) + return self.visit_not_like_op_binary(binary, operator, **kw) def visit_like_op_binary(self, binary, operator, **kw): escape = binary.modifiers.get("escape", None) @@ -2126,7 +2126,7 @@ class SQLCompiler(Compiled): else "" ) - def visit_notlike_op_binary(self, binary, operator, **kw): + def visit_not_like_op_binary(self, binary, operator, **kw): escape = binary.modifiers.get("escape", None) return "%s NOT LIKE %s" % ( binary.left._compiler_dispatch(self, **kw), @@ -2148,7 +2148,7 @@ class SQLCompiler(Compiled): else "" ) - def visit_notilike_op_binary(self, binary, operator, **kw): + def visit_not_ilike_op_binary(self, binary, operator, **kw): escape = binary.modifiers.get("escape", None) return "lower(%s) NOT LIKE lower(%s)" % ( binary.left._compiler_dispatch(self, **kw), @@ -2165,7 +2165,7 @@ class SQLCompiler(Compiled): binary, " BETWEEN SYMMETRIC " if symmetric else " BETWEEN ", **kw ) - def visit_notbetween_op_binary(self, binary, operator, **kw): + def visit_not_between_op_binary(self, binary, operator, **kw): symmetric = binary.modifiers.get("symmetric", False) return self._generate_generic_binary( binary, |