pyeve / eve-sqlalchemy

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

Resource "embedded_fields" does not work #107

Closed bthorben closed 7 years ago

bthorben commented 8 years ago

Steps to reproduce

  1. Have a resource with a relationship to 'related_item'
  2. Define to embed some fields by default by setting: resource_settings['embedded_fields'] = ['related_item']

Actual result 'related_item' is not embedded

Expected result 'related_item' is embedded as if the request contained ?embedded={"related_item": 1}

Note Actually using ?embedded={"related_item": 1} works as expected. It seems like fine_one is responsible for loading embedded objects and only takes into account embedding via the request, not the configuration.

dkellner commented 7 years ago

I just tried this by adding the following two lines toexamples/settings.py (to run with examples/sqla_example.py:

DOMAIN['invoices']['schema']['people']['data_relation']['embeddable'] = True
DOMAIN['invoices']['embedded_fields'] = ['people']

You most likely forgot to set embeddable = True on the field you want to embed, see http://python-eve.org/features.html#embedded-resource-serialization.