pyeve / eve-sqlalchemy

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

Examples not working #79

Closed robbeblock closed 7 years ago

robbeblock commented 9 years ago

Both the examples in the example dir are not working, in particular when running trivial.py and surfing to http://127.0.0.1:5000/people, I get the following error:

sqlalchemy.exc.OperationalError

OperationalError: (sqlite3.OperationalError) no such column: People [SQL: u'SELECT count(*) AS count_1 \nFROM (SELECT People) AS anon_1']

Am I missing something?

botzill commented 9 years ago

I also encounter this issue. Plus, when I try to run sqla_example.py I get:

Traceback (most recent call last): File "sqla_example.py", line 6, in app = Eve(validator=ValidatorSQL, data=SQL) File "/Users/chirgeo/.virtualenvs/tests/lib/python2.7/site-packages/eve/flaskapp.py", line 172, in init self.register_resource(resource, settings) File "/Users/chirgeo/.virtualenvs/tests/lib/python2.7/site-packages/eve/flaskapp.py", line 801, in register_resource self._validate_resource_settings(resource, settings) File "/Users/chirgeo/.virtualenvs/tests/lib/python2.7/site-packages/eve/flaskapp.py", line 322, in _validate_resource_settings self.validate_schema(resource, settings['schema']) File "/Users/chirgeo/.virtualenvs/tests/lib/python2.7/site-packages/eve/flaskapp.py", line 394, in validate_schema "'%s'" % id_field) eve.exceptions.SchemaException: 'unique' key is mandatory for id field '_id'

botzill commented 9 years ago

OK, seems that we get this issue when testing with eve==0.6. I just tested it with 0.5.3 and it works OK.

waynew commented 9 years ago

I can also confirm this - both the error and that rolling back to eve 0.5.3 is a workaround.

The problem has something to do with the way that eve is building up the query, I expect, because it's using the class name (People) rather than the column. It most definitely shouldn't be (SELECT People) in there, it should probably just be SELECT count(*) AS count_1 FROM people AS anon_1, so something is barfing on that table substitution.

Hedde commented 9 years ago

confirmed

jeroenes commented 9 years ago

I got my pre-0.6 code running under eve 0.61 by removing all references to _id and setting the identifier to id throughout, using the new identifier functionality. Hope this works here as well.

And I can confirm the issue with the OperationalError BTW ;-) Started to notice it with my own code, see https://groups.google.com/forum/m/#!topic/python-eve/zy9x2CTubek .

Would greatly appreciate a resolve. Would also be willing to look at it myself, but I would need some pointer about where to start, this is my first project in python (switching from almost two decades in perl ...)

Best regards, Jeroen

bthorben commented 8 years ago

I have exactly the same problem. And downgrading to eve 0.5.3 also solves the problem.

m3talstorm commented 8 years ago

Ditto.

pip install eve==0.5.3

does the trick :)

ralphsmith80 commented 8 years ago

Confirmed

eve 0.5.3 works.

The issue is with Eve. I'll be testing this shortly but the docs provide a way to override the default schema validation.

ralphsmith80 commented 8 years ago

I opened an issue in Eve the override in the docs isn't working.

ralphsmith80 commented 8 years ago

@nicolaiarocci resolved the issue on the Eve end. I've tested this with Eve 0.6.2.dev0 without issue. Others should check but this could probably be closed now.

dkellner commented 7 years ago

At the moment running sqla_example.py doesn't work because of another issue related to relative imports. I will close this as the issues here have been fixed and will open a new one.