pyeve / eve-sqlalchemy

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

Resource level id_field and item_lookup_field are not honoured #99

Closed bthorben closed 7 years ago

bthorben commented 8 years ago

Changing a resources id_field and item_loop_field to a custom value like "login" or "name" fails with

File "eve_sqlalchemy/__init__.py", in insert id_field = getattr(model_instance, self.driver.app.config['ID_FIELD']) AttributeError: 'User' object has no attribute 'id'

nkhalasi commented 8 years ago

I am running into the same issue. Is there a work around other than adding the 'id' attribute?

nkhalasi commented 8 years ago

Putting the below in the model worked as a work around.

    @hybrid_property
    def id(self):
        """
        Eve backward compatibility
        """
        return self.etype
bthorben commented 8 years ago

Looks like a good workaround!

dkellner commented 7 years ago

This should work by now in the current master branch.