pyeve / eve-sqlalchemy

SQLAlchemy data layer for Eve-powered RESTful APIs
http://eve-sqlalchemy.readthedocs.io
Other
232 stars 70 forks source link

Examples from documentation not working (and some missing ones) #69

Closed michalskop closed 9 years ago

michalskop commented 9 years ago

I have tried the _sqlaexample.py from the /examples, but could not replicate some of the examples from the documentation (and similar):

Works:

http://127.0.0.1:5000/people/1
http://127.0.0.1:5000/people?where={"id":"1"}

both return 1 record

http://localhost:5000/people?where={"firstname":"like(\"john\")"}

returns 4 records

http://127.0.0.1:5000/people?where={"lastname":"like(\"oba%\")"}

returns 1 record

Does not work:

http://127.0.0.1:5000/people?where={"lastname":"like(\"%bama\")"}

returns 0 records

http://127.0.0.1:5000/people?where={"firstname":"similar to(\"%ohn\"|\"%acob\")"}

returns 0 records

http://127.0.0.1:5000/people?where={"firstname":"similar to(\"(\'%ohn\'|\'%acob\'\"))"}

returns code 500 and error message simplejson.scanner.JSONDecodeError: Invalid \X escape sequence '\': line 1 column 29 (char 28) // Werkzeug Debugger

http://127.0.0.1:5000/people?where={"firstname":"in(\"(\'John\',\'Fred\'\"))"}

returns code 500 and error message simplejson.scanner.JSONDecodeError: Invalid \X escape sequence '\': line 1 column 29 (char 28) // Werkzeug Debugger

http://127.0.0.1:5000/people?sort=[("lastname", -1, "nullslast")]

returns code 500 and error message _sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near "NULLS": syntax error [SQL: 'SELECT count(*) AS count_1 \nFROM (SELECT people.firstname || ? || people.lastname AS anon_2, people._created AS peoplecreated, people._updated AS people__updated, people._etag AS peopleetag, people.id AS people_id, people.firstname AS people_firstname, people.lastname AS people_lastname \nFROM people ORDER BY people.lastname DESC NULLS LAST) AS anon1'] [parameters: (' ',)] // Werkzeug Debugger

Missing examples It would be great to add examples:

import requests
p = {
    "where": {
        "id": "1"
    }
}
url = "http://127.0.0.1:5000/people"
r = requests.get(url, params = p)
amleczko commented 9 years ago

Can you make a PR with those fixes? It would help a lot!

michalskop commented 9 years ago

Unfortunately, I cannot make a pull request. I actually do not know how to make the Does not work stuff to get working, nor the Missing examples (even after several hours of playing with it).