pyeve / eve-sqlalchemy

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

PUT to sub-resource fails in upcoming eve #60

Closed joystein closed 9 years ago

joystein commented 9 years ago

It seem that the - as of yet - unreleased eve version specified by tox, makes PUT to sub-resource fail, as can also be seen in travis logs when clicking the build badge.

Looking at the difference of:

py.test eve_sqlalchemy/tests/put.py::TestPutSQL::test_put_subresource

and

tox -e py33 -- eve_sqlalchemy/tests/put.py::TestPutSQL::test_put_subresource

The first one installed with python setup.py develop inside a virtualenv and the second run as is, I see that the document argument to eve_sqlalchemy.replace differs and contains respectively:

{
    'number': 5,
    '_etag': '734feae487343ac9ba703fa1cdb13cf1b32e18c3',
    '_updated': datetime.datetime(2015, 7, 21, 13, 16, 41),
    '_created': datetime.datetime(2015, 7, 21, 15, 16, 41, 521290),
    '_id': 2
}

and

{
    'number': 5,
    '_etag': '41b6372bf938270b3d8e2db9d2bbc9dde7bd2a35',
    '_updated': datetime.datetime(2015, 7, 21, 13, 16, 38),
    '_created': datetime.datetime(2015, 7, 21, 15, 16, 38, 502411),
    'people': '102',
    '_id': 2
}

That is, people, a relationship from Invoives to People is now included in document, while that does not seem to have been the case before. And it seems this breaks the creation of the new model instance:

model_instance = model(**document)

Leading to a 'str' object has no attribute '_sa_instance_state' that is eventualy eaten by an Exception catch in eve.methods.put.put_internal

amleczko commented 9 years ago

Yes that's true - I have pinned tox to Eve >=0.5,<0.6. In the meantime I hope to fix it so we can be prepared for next Eve release.

joystein commented 9 years ago

What about creating a develop branch that follows the develop branch of eve?

amleczko commented 9 years ago

That's actually a good idea - here you go - https://github.com/RedTurtle/eve-sqlalchemy/tree/develop

joystein commented 9 years ago

Thanks a lot!

amleczko commented 9 years ago

If you want to make a patch please open PR.

joystein commented 9 years ago

I might try to do so at a later stage. For now though, i think it would be good if you kept this (and other recently closed issues) open so that they are visible to the community. Asking for PRs does not make issues magically go away.