def visit_contains_op_binary(self, binary, operator, **kw):
binary = binary._clone()
percent = self._like_percent_literal
- binary.right = percent.__add__(binary.right).__add__(percent)
+ binary.right = percent.concat(binary.right).concat(percent)
return self.visit_like_op_binary(binary, operator, **kw)
def visit_not_contains_op_binary(self, binary, operator, **kw):
binary = binary._clone()
percent = self._like_percent_literal
- binary.right = percent.__add__(binary.right).__add__(percent)
+ binary.right = percent.concat(binary.right).concat(percent)
return self.visit_not_like_op_binary(binary, operator, **kw)
def visit_startswith_op_binary(self, binary, operator, **kw):
binary = binary._clone()
percent = self._like_percent_literal
- binary.right = percent.__radd__(binary.right)
+ binary.right = percent._rconcat(binary.right)
return self.visit_like_op_binary(binary, operator, **kw)
def visit_not_startswith_op_binary(self, binary, operator, **kw):
binary = binary._clone()
percent = self._like_percent_literal
- binary.right = percent.__radd__(binary.right)
+ binary.right = percent._rconcat(binary.right)
return self.visit_not_like_op_binary(binary, operator, **kw)
def visit_endswith_op_binary(self, binary, operator, **kw):
binary = binary._clone()
percent = self._like_percent_literal
- binary.right = percent.__add__(binary.right)
+ binary.right = percent.concat(binary.right)
return self.visit_like_op_binary(binary, operator, **kw)
def visit_not_endswith_op_binary(self, binary, operator, **kw):
binary = binary._clone()
percent = self._like_percent_literal
- binary.right = percent.__add__(binary.right)
+ binary.right = percent.concat(binary.right)
return self.visit_not_like_op_binary(binary, operator, **kw)
def visit_like_op_binary(self, binary, operator, **kw):
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(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(concat('%%', %s), '%%')",
+ checkparams={"x_1": b"y"},
+ dialect="mysql",
+ )
+
def test_contains_escape(self):
self.assert_compile(
column("x").contains("a%b_c", escape="\\"),
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"),
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="\\"),