]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
General fixes
authorAnton Kovalevich <kai3341@gmail.com>
Thu, 1 Apr 2021 21:11:09 +0000 (00:11 +0300)
committerAnton Kovalevich <kai3341@gmail.com>
Thu, 1 Apr 2021 21:11:09 +0000 (00:11 +0300)
lib/sqlalchemy/dialects/mysql/base.py
test/dialect/mysql/test_compiler.py

index 8410e9aeae5d6684f78fda8a1cb76d7fc38dac83..648a4e6567bc5ea9fa3086baeceaa16b2fda5232 100644 (file)
@@ -1609,9 +1609,11 @@ class MySQLCompiler(compiler.SQLCompiler):
         backward compatibility
         """
 
-        boolean_mode = kw.pop('mysql_boolean_mode', True)
-        natural_language = kw.pop('mysql_natural_language', False)
-        query_expansion = kw.pop('mysql_query_expansion', False)
+        modifiers = binary.modifiers
+
+        boolean_mode = modifiers.get('mysql_boolean_mode', True)
+        natural_language = modifiers.get('mysql_natural_language', False)
+        query_expansion = modifiers.get('mysql_query_expansion', False)
 
         flag_combination = (boolean_mode, natural_language, query_expansion)
 
index f0a9b626fde56d7a31b911db9fcbacea0f1f779e..a21f191ed9a0724f369aaa24943082ece3672341 100644 (file)
@@ -433,10 +433,12 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
     def test_match_compile_modifiers(self):
         matchtable = table("matchtable", column("title", String))
         title = matchtable.c.title
+        dialect = mysql.dialect()
 
         self.assert_compile(
             title.match("somstr", mysql_boolean_mode=False),
             "MATCH (matchtable.title) AGAINST (%s)",
+            dialect=dialect,
         )
 
         self.assert_compile(
@@ -446,6 +448,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
                 mysql_natural_language=True,
             ),
             "MATCH (matchtable.title) AGAINST (%s IN NATURAL LANGUAGE MODE)",
+            dialect=dialect,
         )
 
         self.assert_compile(
@@ -455,6 +458,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
                 mysql_query_expansion=True,
             ),
             "MATCH (matchtable.title) AGAINST (%s WITH QUERY EXPANSION)",
+            dialect=dialect,
         )
 
         self.assert_compile(
@@ -466,11 +470,14 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
             ),
             "MATCH (matchtable.title) AGAINST "
             "(%s IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION)",
+            dialect=dialect,
         )
 
     def test_match_compile_modifiers_fail(self):
         matchtable = table("matchtable", column("title", String))
         title = matchtable.c.title
+        dialect = mysql.dialect()
+
         msg = "Flag combination does not make sence: " \
             "mysql_boolean_mode=%s, " \
             "mysql_natural_language=%s, " \
@@ -479,26 +486,32 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
         assert_raises_message(
             exc.CompileError,
             msg % (True, True, True),
-            title.match,
-            "somstr",
-            mysql_natural_language=True,
-            mysql_query_expansion=True,
+            title.match(
+                "somstr",
+                mysql_natural_language=True,
+                mysql_query_expansion=True,
+            ).compile,
+            dialect=dialect,
         )
 
         assert_raises_message(
             exc.CompileError,
             msg % (True, False, True),
-            title.match,
-            "somstr",
-            mysql_query_expansion=True,
+            title.match(
+                "somstr",
+                mysql_query_expansion=True,
+            ).compile,
+            dialect=dialect,
         )
 
         assert_raises_message(
             exc.CompileError,
             msg % (True, True, False),
-            title.match,
-            "somstr",
-            mysql_natural_language=True,
+            title.match(
+                "somstr",
+                mysql_natural_language=True,
+            ).compile,
+            dialect=dialect,
         )
 
     def test_concat_compile_kw(self):