|
| 1 | +Python RQL |
| 2 | +========== |
| 3 | + |
| 4 | +[](https://pypi.org/project/lib-rql/) |
| 5 | +[](https://codecov.io/gh/cloudblue/lib-rql) |
| 6 | +[](https://pypi.python.org/pypi/lib-rql/) |
| 7 | +[](https://sonarcloud.io/dashboard?id=lib-rql) |
| 8 | + |
| 9 | +RQL |
| 10 | +--- |
| 11 | + |
| 12 | +RQL (Resource query language) is designed for modern application development. It is built for the web, ready for NoSQL, and highly extensible with simple syntax. |
| 13 | +This is a query language fast and convenient database interaction. RQL was designed for use in URLs to request object-style data structures. |
| 14 | + |
| 15 | +[RQL Reference](https://connect.cloudblue.com/community/api/rql/) |
| 16 | + |
| 17 | +Notes |
| 18 | +----- |
| 19 | + |
| 20 | +Parsing is done with [Lark](https://github.com/lark-parser/lark) ([cheatsheet](https://lark-parser.readthedocs.io/en/latest/lark_cheatsheet.pdf)). |
| 21 | +The current parsing algorithm is [LALR(1)](https://www.wikiwand.com/en/LALR_parser) with standard lexer. |
| 22 | + |
| 23 | +Supported operators |
| 24 | +============================= |
| 25 | +1. Comparison (eq, ne, gt, ge, lt, le, like, ilike, search) |
| 26 | +2. List (in, out) |
| 27 | +3. Logical (and, or, not) |
| 28 | +4. Constants (null(), empty()) |
| 29 | +5. Ordering (ordering) |
| 30 | +6. Select (select) |
| 31 | +7. Tuple (t) |
| 32 | + |
| 33 | + |
| 34 | +Example |
| 35 | +======= |
| 36 | +```python |
| 37 | +from py_rql import parse |
| 38 | +from py_rql.exceptions import RQLFilterError |
| 39 | + |
| 40 | +try: |
| 41 | + tree = parse('eq(key,value)') |
| 42 | +except RQLFilterError: |
| 43 | + pass |
| 44 | +``` |
| 45 | + |
| 46 | +Notes |
| 47 | +===== |
| 48 | +0. Values with whitespaces or special characters, like ',' need to have "" or '' |
| 49 | +1. Supported date format is ISO8601: 2019-02-12 |
| 50 | +2. Supported datetime format is ISO8601: 2019-02-12T10:02:00 / 2019-02-12T10:02Z / 2019-02-12T10:02:00+03:00 |
| 51 | + |
| 52 | + |
| 53 | +Development |
| 54 | +=========== |
| 55 | + |
| 56 | +1. Python 3.6+ |
| 57 | +0. Install dependencies `requirements/dev.txt` |
| 58 | + |
| 59 | +Testing |
| 60 | +======= |
| 61 | + |
| 62 | +1. Python 3.6+ |
| 63 | +0. Install dependencies `requirements/test.txt` |
| 64 | + |
| 65 | +Check code style: `flake8` |
| 66 | +Run tests: `pytest` |
| 67 | + |
| 68 | +Tests reports are generated in `tests/reports`. |
| 69 | +* `out.xml` - JUnit test results |
| 70 | +* `coverage.xml` - Coverage xml results |
| 71 | + |
| 72 | +To generate HTML coverage reports use: |
| 73 | +`--cov-report html:tests/reports/cov_html` |
| 74 | + |
0 commit comments