]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
okay, i have add this ugly api
authorAnton Kovalevich <kai3341@gmail.com>
Sat, 5 Jun 2021 02:55:37 +0000 (05:55 +0300)
committerAnton Kovalevich <kai3341@gmail.com>
Sat, 5 Jun 2021 02:55:37 +0000 (05:55 +0300)
lib/sqlalchemy/dialects/mysql/base.py
test/dialect/mysql/test_compiler.py

index ee93604eb25468824e2e07dcbb8d008e81f2553d..2396ffeeeb8c8f6c8143d95e407f7848f30b23a4 100644 (file)
@@ -1626,7 +1626,18 @@ class MySQLCompiler(compiler.SQLCompiler):
                 "Flag combination does not make sence: %s" % flags
             )
 
-        match_clause = self.process(binary.left, **kw)
+        match_clause = binary.left
+        mysql_additional_cols = modifiers.get('mysql_additional_cols')
+
+        if mysql_additional_cols:
+            match_clause = (match_clause, *mysql_additional_cols)
+            match_clause = elements.BooleanClauseList._construct_raw(
+                operators.comma_op,
+                clauses=match_clause,
+            )
+            match_clause.group = False
+
+        match_clause = self.process(match_clause, **kw)
         against_clause = self.process(binary.right, **kw)
 
         if any(flag_combination):
index cd7034bfe4b38466660b39b52729a3cf998756ce..9adabf42bc1137fcc715f4aae8cc56492cc4e6fd 100644 (file)
@@ -513,6 +513,22 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
             dialect=self.__dialect__,
         )
 
+    def test_match_additional_cols(self):
+        matchtable = table(
+            "matchtable",
+            column("title", String),
+            column("comment", String),
+        )
+
+        self.assert_compile(
+            matchtable.c.title.match(
+                "somstr",
+                mysql_additional_cols=[matchtable.c.comment],
+            ),
+            "MATCH (matchtable.title, matchtable.comment) "
+            "AGAINST (%s IN BOOLEAN MODE)",
+        )
+
     def test_concat_compile_kw(self):
         expr = literal("x", type_=String) + literal("y", type_=String)
         self.assert_compile(expr, "concat('x', 'y')", literal_binds=True)