Skip to content

Commit 89320a6

Browse files
authored
Merge pull request #54 from cloudblue/fix/LITE-25309_fix-or-chain
LITE-25309 update lib-rql version to fix ambiguous parsing of comma-s…
2 parents 8c61901 + 8e75cd1 commit 89320a6

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

Diff for: requirements/dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
lib-rql>=1.1.4,<2
1+
lib-rql>=1.1.5,<2
22
Django>=2.2.19

Diff for: requirements/test.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ flake8-comprehensions==3.7.0
1919
flake8-debugger==4.0.0
2020
flake8-eradicate==1.1.0
2121
flake8-import-order==0.18.1
22-
flake8-string-format==0.3.0
22+
flake8-string-format==0.3.0
23+
importlib-metadata>=4.0.0,<5.0.0

Diff for: tests/test_filter_cls/test_apply_filters.py

+30-13
Original file line numberDiff line numberDiff line change
@@ -65,40 +65,57 @@ def test_searching(searching_tpl):
6565
@pytest.mark.django_db
6666
@pytest.mark.parametrize('operator', ['&', ','])
6767
def test_and(operator):
68-
email, title = '[email protected]', 'book'
69-
comp1 = 'title={0}'.format(title)
70-
comp2 = 'eq(author.email,{0})'.format(email)
71-
query = '{comp1}{op}{comp2}'.format(comp1=comp1, op=operator, comp2=comp2)
68+
email, title, stars = '[email protected]', 'book', 10
69+
comps = [
70+
'title={0}'.format(title),
71+
'eq(author.email,{0})'.format(email),
72+
'gt(github_stars,{0})'.format(stars),
73+
]
74+
query = operator.join(comps)
75+
query_func_style = 'and({0})'.format(','.join(comps))
7276

7377
authors = [
7478
Author.objects.create(email='[email protected]'),
7579
Author.objects.create(email=email),
7680
]
77-
books = [Book.objects.create(author=authors[index], title=title) for index in range(2)]
81+
books = [
82+
Book.objects.create(author=authors[0], title=title, github_stars=11),
83+
Book.objects.create(author=authors[1], title='title', github_stars=11),
84+
Book.objects.create(author=authors[1], title=title, github_stars=11),
85+
]
7886

79-
expected = [books[1]]
87+
expected = [books[2]]
8088
assert apply_filters(query) == expected
8189
assert apply_filters('{q}{op}{q}'.format(q=query, op=operator)) == expected
82-
assert apply_filters('and({comp1},{comp2})'.format(comp1=comp1, comp2=comp2)) == expected
90+
assert apply_filters(query_func_style) == expected
8391

8492

8593
@pytest.mark.django_db
8694
@pytest.mark.parametrize('operator', ['|', ';'])
8795
def test_or(operator):
88-
email, title = '[email protected]', 'book'
89-
comp1 = 'title={0}'.format(title)
90-
comp2 = 'eq(author.email,{0})'.format(email)
91-
query = '({comp1}{op}{comp2})'.format(comp1=comp1, op=operator, comp2=comp2)
96+
email, title, stars = '[email protected]', 'book', '10'
97+
comps = [
98+
'title={0}'.format(title),
99+
'eq(author.email,{0})'.format(email),
100+
'gt(github_stars,{0})'.format(stars),
101+
]
102+
query = '({0})'.format(operator.join(comps))
103+
query_func_style = 'or({0})'.format(','.join(comps))
92104

93105
authors = [
94106
Author.objects.create(email='[email protected]'),
95107
Author.objects.create(email=email),
96108
]
97-
books = [Book.objects.create(author=authors[index], title=title) for index in range(2)]
109+
books = [
110+
Book.objects.create(author=authors[0], title=title, github_stars=2),
111+
Book.objects.create(author=authors[1], title='1', github_stars=5),
112+
Book.objects.create(author=authors[0], title='2', github_stars=11),
113+
]
98114

99115
expected = books
116+
100117
assert apply_filters(query) == expected
101-
assert apply_filters('or({comp1},{comp2})'.format(comp1=comp1, comp2=comp2)) == expected
118+
assert apply_filters(query_func_style) == expected
102119

103120

104121
@pytest.mark.django_db

0 commit comments

Comments
 (0)