diff options
Diffstat (limited to 'test/sql/test_operators.py')
-rw-r--r-- | test/sql/test_operators.py | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 2411fb0a3..830a5eb0f 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -3087,6 +3087,36 @@ class ComposedLikeOperatorsTest(fixtures.TestBase, testing.AssertsCompiledSQL): checkparams={"x_1": "y"}, ) + def test_contains_encoded(self): + self.assert_compile( + column("x").contains(b"y"), + "x LIKE '%' || :x_1 || '%'", + checkparams={"x_1": b"y"}, + ) + + def test_not_contains_encoded(self): + self.assert_compile( + ~column("x").contains(b"y"), + "x NOT LIKE '%' || :x_1 || '%'", + checkparams={"x_1": b"y"}, + ) + + def test_contains_encoded_mysql(self): + self.assert_compile( + column("x").contains(b"y"), + "x LIKE concat('%%', %s, '%%')", + checkparams={"x_1": b"y"}, + dialect="mysql", + ) + + def test_not_contains_encoded_mysql(self): + self.assert_compile( + ~column("x").contains(b"y"), + "x NOT LIKE concat('%%', %s, '%%')", + checkparams={"x_1": b"y"}, + dialect="mysql", + ) + def test_contains_escape(self): self.assert_compile( column("x").contains("a%b_c", escape="\\"), @@ -3250,6 +3280,36 @@ class ComposedLikeOperatorsTest(fixtures.TestBase, testing.AssertsCompiledSQL): checkparams={"x_1": "a^%b^_c/d^^e"}, ) + def test_startswith_encoded(self): + self.assert_compile( + column("x").startswith(b"y"), + "x LIKE :x_1 || '%'", + checkparams={"x_1": b"y"}, + ) + + def test_startswith_encoded_mysql(self): + self.assert_compile( + column("x").startswith(b"y"), + "x LIKE concat(%s, '%%')", + checkparams={"x_1": b"y"}, + dialect="mysql", + ) + + def test_not_startswith_encoded(self): + self.assert_compile( + ~column("x").startswith(b"y"), + "x NOT LIKE :x_1 || '%'", + checkparams={"x_1": b"y"}, + ) + + def test_not_startswith_encoded_mysql(self): + self.assert_compile( + ~column("x").startswith(b"y"), + "x NOT LIKE concat(%s, '%%')", + checkparams={"x_1": b"y"}, + dialect="mysql", + ) + def test_not_startswith(self): self.assert_compile( ~column("x").startswith("y"), @@ -3324,6 +3384,28 @@ class ComposedLikeOperatorsTest(fixtures.TestBase, testing.AssertsCompiledSQL): checkparams={"x_1": "y"}, ) + def test_endswith_encoded(self): + self.assert_compile( + column("x").endswith(b"y"), + "x LIKE '%' || :x_1", + checkparams={"x_1": b"y"}, + ) + + def test_endswith_encoded_mysql(self): + self.assert_compile( + column("x").endswith(b"y"), + "x LIKE concat('%%', %s)", + checkparams={"x_1": b"y"}, + dialect="mysql", + ) + + def test_not_endswith_encoded(self): + self.assert_compile( + ~column("x").endswith(b"y"), + "x NOT LIKE '%' || :x_1", + checkparams={"x_1": b"y"}, + ) + def test_endswith_escape(self): self.assert_compile( column("x").endswith("a%b_c", escape="\\"), |