pyeve / eve-sqlalchemy

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

Many-to-many issue #205

Closed ernests closed 3 years ago

ernests commented 3 years ago

Hi! Have used Python-eve for a while now and had to switch from Mongo to eve-sqlalchemy backend.

I'm having several collections where I have one-to-one, many-to-many case. I have multiple items which can have multiple categories. I have looked into https://github.com/pyeve/eve-sqlalchemy/tree/master/eve_sqlalchemy/examples/many_to_many. I built example and tried to post parent with children:

endpoint = "http://127.0.0.1:5000/"
r = requests.post(f"{endpoint}parents", data= {"id": 23, "children": [2]})
r.json()

Response:

{'_status': 'ERR',
 '_issues': {'children': 'must be of list type'},
 '_error': {'code': 422,
  'message': 'Insertion failure: 1 document(s) contain(s) error(s)'}}

Only time I'm not getting error is when I post list().

Am I missing something about the way it is supposed to work?

ernests commented 3 years ago

Problem might have been on my side as I didn't delete existing Postgres tables before changing schema. Closing this.