From: Anton Kovalevich Date: Thu, 1 Apr 2021 21:11:09 +0000 (+0300) Subject: General fixes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4641cd405397046e273d587848fb3eaaf4c6271;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git General fixes --- diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 8410e9aeae..648a4e6567 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -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) diff --git a/test/dialect/mysql/test_compiler.py b/test/dialect/mysql/test_compiler.py index f0a9b626fd..a21f191ed9 100644 --- a/test/dialect/mysql/test_compiler.py +++ b/test/dialect/mysql/test_compiler.py @@ -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):