]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix docs and tests
authorAnton Kovalevich <kai3341@gmail.com>
Thu, 1 Apr 2021 14:35:24 +0000 (17:35 +0300)
committerAnton Kovalevich <kai3341@gmail.com>
Thu, 1 Apr 2021 14:35:24 +0000 (17:35 +0300)
lib/sqlalchemy/dialects/mysql/expression.py
test/dialect/mysql/test_compiler.py

index ca442e115fa1ce255c6a42f009b8b530413682b7..49cdc43fd254ee7f2dbcd66ceaaea9be0e7e0df9 100644 (file)
@@ -58,8 +58,7 @@ class match(ColumnElement):
     All positional arguments passed to :func:`.match`, typically should be a
      :class:`_expression.ColumnElement` instances
 
-    :param against: typically scalar expression to be coerced into a ``str``,
-     but may be a :class:`_expression.ColumnElement` instance
+    :param against: typically scalar expression to be coerced into a ``str``
 
     :param flags: optional ``dict``
 
index dae2862993136d66eb9a0d2ad7b9e177bab862a3..f0a9b626fde56d7a31b911db9fcbacea0f1f779e 100644 (file)
@@ -1,7 +1,5 @@
 # coding: utf-8
 
-from finctools import partial
-
 from sqlalchemy import BLOB
 from sqlalchemy import BOOLEAN
 from sqlalchemy import Boolean
@@ -432,30 +430,35 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
             literal_binds=True,
         )
 
-    def test_match_compile_kw_mysql(self):
+    def test_match_compile_modifiers(self):
         matchtable = table("matchtable", column("title", String))
+        title = matchtable.c.title
+
         self.assert_compile(
-            matchtable.c.title.match("somstr", mysql_boolean_mode=False),
+            title.match("somstr", mysql_boolean_mode=False),
             "MATCH (matchtable.title) AGAINST (%s)",
         )
+
         self.assert_compile(
-            matchtable.c.title.match(
+            title.match(
                 "somstr",
                 mysql_boolean_mode=False,
                 mysql_natural_language=True,
             ),
             "MATCH (matchtable.title) AGAINST (%s IN NATURAL LANGUAGE MODE)",
         )
+
         self.assert_compile(
-            matchtable.c.title.match(
+            title.match(
                 "somstr",
                 mysql_boolean_mode=False,
                 mysql_query_expansion=True,
             ),
             "MATCH (matchtable.title) AGAINST (%s WITH QUERY EXPANSION)",
         )
+
         self.assert_compile(
-            matchtable.c.title.match(
+            title.match(
                 "somstr",
                 mysql_boolean_mode=False,
                 mysql_natural_language=True,
@@ -465,47 +468,37 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
             "(%s IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION)",
         )
 
+    def test_match_compile_modifiers_fail(self):
+        matchtable = table("matchtable", column("title", String))
+        title = matchtable.c.title
+        msg = "Flag combination does not make sence: " \
+            "mysql_boolean_mode=%s, " \
+            "mysql_natural_language=%s, " \
+            "mysql_query_expansion=%s"
+
         assert_raises_message(
             exc.CompileError,
-            "Flag combination does not make sence: "
-            "mysql_boolean_mode=True, "
-            "mysql_natural_language=True, "
-            "mysql_query_expansion=True",
-            partial(
-                matchtable.c.title.match,
-                "somstr",
-                mysql_natural_language=True,
-                mysql_query_expansion=True,
-            ),
-            dialect=mysql.dialect(),
+            msg % (True, True, True),
+            title.match,
+            "somstr",
+            mysql_natural_language=True,
+            mysql_query_expansion=True,
         )
 
         assert_raises_message(
             exc.CompileError,
-            "Flag combination does not make sence: "
-            "mysql_boolean_mode=True, "
-            "mysql_natural_language=False, "
-            "mysql_query_expansion=True",
-            partial(
-                matchtable.c.title.match,
-                "somstr",
-                mysql_query_expansion=True,
-            ),
-            dialect=mysql.dialect(),
+            msg % (True, False, True),
+            title.match,
+            "somstr",
+            mysql_query_expansion=True,
         )
 
         assert_raises_message(
             exc.CompileError,
-            "Flag combination does not make sence: "
-            "mysql_boolean_mode=True, "
-            "mysql_natural_language=True, "
-            "mysql_query_expansion=False",
-            partial(
-                matchtable.c.title.match,
-                "somstr",
-                mysql_natural_language=True,
-            ),
-            dialect=mysql.dialect(),
+            msg % (True, True, False),
+            title.match,
+            "somstr",
+            mysql_natural_language=True,
         )
 
     def test_concat_compile_kw(self):