]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Use immutabledict
authorAnton Kovalevich <kai3341@gmail.com>
Tue, 8 Jun 2021 09:47:33 +0000 (12:47 +0300)
committerAnton Kovalevich <kai3341@gmail.com>
Tue, 8 Jun 2021 09:47:33 +0000 (12:47 +0300)
lib/sqlalchemy/dialects/mysql/expression.py

index 287f6f0718ebd33c40065898d5023817e9ecda74..dd05818d3b1cb45ea969e8179709edf8914b8fc4 100644 (file)
@@ -4,6 +4,7 @@ from sqlalchemy import exc
 from sqlalchemy.ext.compiler import compiles
 from sqlalchemy.sql import elements
 from sqlalchemy.sql import operators
+from sqlalchemy.util import immutabledict
 
 
 def property_enables_flag(flag_name):
@@ -11,8 +12,8 @@ def property_enables_flag(flag_name):
         @property
         @wraps(target)
         def inner(self):
-            new_flags = self.flags.copy()
-            new_flags[flag_name] = True
+            update = {flag_name: True}
+            new_flags = self.flags.union(update)
 
             return match_(
                 self.clause,
@@ -99,11 +100,11 @@ class match_(elements.ColumnElement):
 
     """
 
-    default_flags = {
-        "mysql_boolean_mode": False,
-        "mysql_natural_language": False,
-        "mysql_query_expansion": False,
-    }
+    default_flags = immutabledict(
+        mysql_boolean_mode=False,
+        mysql_natural_language=False,
+        mysql_query_expansion=False,
+    )
 
     def __init__(self, *clauselist, **kwargs):
         clauselist_len = len(clauselist)
@@ -126,7 +127,7 @@ class match_(elements.ColumnElement):
             raise exc.CompileError("Can not match without against")
 
         self.against = against
-        self.flags = flags or self.default_flags.copy()
+        self.flags = flags or self.default_flags
 
     @property_enables_flag("mysql_boolean_mode")
     def in_boolean_mode(self):