This commit is contained in:
Amos Rimon 2019-10-31 09:06:26 +02:00
Родитель 4e9c2183b6
Коммит 60e12d6c29
2 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -253,6 +253,9 @@ class StringExpression(BaseExpression):
def contains(self, other: StringType, case_sensitive: bool = False) -> BooleanExpression:
return BooleanExpression.binary_op(self, ' contains_cs ' if case_sensitive else ' contains ', other)
def not_contains(self, other: StringType, case_sensitive: bool = False) -> BooleanExpression:
return BooleanExpression.binary_op(self, ' !contains_cs ' if case_sensitive else ' !contains ', other)
def startswith(self, other: StringType, case_sensitive: bool = False) -> BooleanExpression:
return BooleanExpression.binary_op(self, ' startswith_cs ' if case_sensitive else ' startswith ', other)

Просмотреть файл

@ -11,6 +11,20 @@ class TestExpressions(TestBase):
' | where foo contains "bar"',
Query().where(col.foo.contains('bar')).render(),
)
self.assertEqual(
' | where foo contains_cs "bar"',
Query().where(col.foo.contains('bar', True)).render(),
)
def test_not_contains(self):
self.assertEqual(
' | where foo !contains "bar"',
Query().where(col.foo.not_contains('bar')).render(),
)
self.assertEqual(
' | where foo !contains_cs "bar"',
Query().where(col.foo.not_contains('bar', True)).render(),
)
def test_array_access(self):
self.assertEqual(