Skip to content

Commit

Permalink
Merge pull request #1 from maxipavlovic/feature/LITE-13900
Browse files Browse the repository at this point in the history
LITE-13900 Added support for %20 in like/ilike operator
  • Loading branch information
vgrebenschikov authored Jun 15, 2020
2 parents 92baaef + b2db6aa commit f224e83
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ RQL (Resource query language) is designed for modern application development. It
This is a query language fast and convenient database interaction. RQL was designed for use in URLs to request object-style data structures.


[RQL Reference](https://connect.cloudblue.com/community/api/rql/)

[RQL for Web](https://www.sitepen.com/blog/resource-query-language-a-query-language-for-the-web-nosql/)
[RQL Reference](https://docs.cloudblue.com/oa/8.0/sdk/api/rest/rql/index.html)

Notes
-----
Expand Down Expand Up @@ -193,7 +194,7 @@ Development
Testing
=======

1. Python 3.5+
1. Python 3.6+
0. Install dependencies `requirements/test.txt`
0. `export PYTHONPATH=/your/path/to/django-rql/`

Expand Down
2 changes: 1 addition & 1 deletion dj_rql/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
| /'[^']*'/
UNQUOTED_VAL: NULL
| EMPTY
| /[\w\-\*\+\\]/ /[\w\.\-\:\+\@\*\\]/*
| /[\w\-\*\+\\]/ /[\w\.\s\-\:\+\@\*\\]/*
EMPTY: "empty()"
NULL: "null()"
Expand Down
3 changes: 2 additions & 1 deletion dj_rql/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def select(self, args):

if props:
for prop in props:
self._filtered_props.add(prop.replace('-', '').replace('+', ''))
if not prop.startswith('-'):
self._filtered_props.add(prop.replace('+', ''))

return Q()

Expand Down
8 changes: 8 additions & 0 deletions tests/test_drf/test_common_drf_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def test_reflecting_star_in_like(api_client, clear_cache):
assert response.data == [{'id': books[0].pk}]


@pytest.mark.django_db
def test_reflecting_20_and_minus(api_client, clear_cache):
books = [Book.objects.create(title='A B-c0')]
response = api_client.get(reverse('book-list') + r'?like(title,*A%20 B-c0*)')
assert response.status_code == HTTP_200_OK
assert response.data == [{'id': books[0].pk}]


@pytest.mark.django_db
def test_list(api_client, clear_cache):
books = [Book.objects.create() for _ in range(2)]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parser/test_searching.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
search_operators = [SearchOperators.LIKE, SearchOperators.I_LIKE]

SEARCH_OKAY_VALUES = OK_VALUES[:]
SEARCH_OKAY_VALUES.extend(['*v', 'v*', '*v*', '*v*v', '*v*v*', '"*v v*"'])
SEARCH_OKAY_VALUES.extend(['*v', 'v*', '*v*', '*v*v', '*v*v*', '"*v v*"', 'v v'])


def search_transform(operator, prop, value):
Expand Down

0 comments on commit f224e83

Please sign in to comment.