-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Many to many key error #596
Comments
Hi @upmauro! Thanks for the issue report. Can you provide a minimal working example (i.e. without the irrelevant columns, preprocessors, etc.) that demonstrates this bug, so that I can run the code on my own machine to try and debug it? |
First of all, thanks for your great project. I created snippet to reproduce standalone (sorry my bad code, i'm studying). Sourcehttps://gist.github.com/upmauro/3534c43ab8688bee9d2a86438f23958e Error (when try GET /api/table_a)File "/home/upmauro/Work/journey/wr-platform-backend/env/src/flask-restless/flask_restless/serialization/serializers.py", line 107, in create_relationship |
This definitely seems to be a bug. Many-to-many relationships are basically untested in the development version of Flask-Restless right now. See also issue #480. I will work on debugging this. In the minimal working example you provided (thanks!), what kind of response would you expect from the request |
Hi! I can't find specs about this situation on http://jsonapi.org/ but in my opnion when you GET "TableA" a element what the schema is referenced by a many to many schema "TableAB", return just information about the main element "TableA". If you need informations about both, call GET on "TableAB" What do you think? Sorry my bad english. |
Let me clarify my question. On a request HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"data": {
"id": "1",
"links": {
"self": "http://example.com/api/table_a/1"
},
"relationships": {
"table_abs": {
"data": [
{
"id": 1,
"type": "table_ab"
},
...
],
"links": {
"related": "http://example.com/api/table_a/1/",
"self": "http://example.com/api/table_a/1/relationships/table_abs"
}
}
},
"type": "person"
}
} or HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"data": {
"id": "1",
"links": {
"self": "http://example.com/api/table_a/1"
},
"relationships": {
"tableb": {
"data": [
{
"id": 1,
"type": "table_b"
},
...
],
"links": {
"related": "http://example.com/api/table_a/1/",
"self": "http://example.com/api/table_a/1/relationships/tableb"
}
}
},
"type": "person"
}
} Perhaps in most cases the information that the client really cares about is in |
@jfinkels , second option looks perfect to me. |
API
manager.create_api(Vehicle, methods=['GET', 'POST', 'DELETE'], preprocessors=dict(GET_SINGLE=[auth_func], GET_MANY=[auth_func]), primary_key='id')
MODELS
Error
The text was updated successfully, but these errors were encountered: