Closed samtux closed 9 years ago
As per your gist, your Pregnunta model is defined with an id
column however Eve defaults to _id
. You should try to set the ID_FIELD to id
in your settings and see if it solves your issue.
Thanks @kiniou, I updated the settings[1] and added the line "ID_FIELD: 'id'" as you suggest [2]. However I have two tables with different column name primary key in this case PREGUNTA with column primary key name 'id' and TERCERO with column named primary key 'numter'. It is possible to have different ID_FIELD depending on the column primary key name of each table?.
For the above settings works properly:
http://0.0.0.0:5000/pregunta/25
But it does not work for the next case column name 'numter':
http http://0.0.0.0:5000/tercero/19496819
I really want to congratulate you for this great software, service response time is very fast and its configuration is very easy.
[1] https://gist.github.com/samtux/e7f85eb6bad8e3ea5b7d#file-ontrack_rest-py-L37 [2] https://github.com/RedTurtle/eve-sqlalchemy/blob/5b5d6399bd241e96ee9fec7bb19e38d4550167f9/docs/tutorial.rst#how-to-adjust-the-primary-column-name
After testing the trivial.py
example, i found that after putting ID_FIELD: 'id'
in the settings doesn't work either and i think there might be a race condition between models registration in the domain and application initialization.
Actually, the register_schema
is using the Eve's default settings for the item_lookup_field
because the app.config
is not yet initialized.
Your first query is working since you override the item_lookup_field
in the corresponding domain entry for Pregunta
. You should do the same for your Tercero
domain by using item_lookup_field:numter
.
You can also take a look at the hybrid_property
method which may be used to declare some id
attributes which will point to a different column name(cf. examples/tables.py). But this may be considered as hacky way to do it :smile:.
PS: You should congratulate @amleczko for Eve-SQLAlchemy and @nicolaiarocci for Eve. I'm only some modest contributors among others :wink:.
I have configured the REST API with a connection to Oracle:
https://gist.github.com/samtux/e7f85eb6bad8e3ea5b7d
When I request all records as:
Returns all records correctly. But when I ask a single record returns an error, such as: