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)
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(
mysql_natural_language=True,
),
"MATCH (matchtable.title) AGAINST (%s IN NATURAL LANGUAGE MODE)",
+ dialect=dialect,
)
self.assert_compile(
mysql_query_expansion=True,
),
"MATCH (matchtable.title) AGAINST (%s WITH QUERY EXPANSION)",
+ dialect=dialect,
)
self.assert_compile(
),
"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, " \
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):