Skip to content
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

Provide support for contextually-readonly properties, and odata services which don't follow Foreign Key BINDs #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Support foreign key props to service, without service support for @od…
…ata.bind
jonnerd154 committed Oct 9, 2024
commit 9f89d920a10ed443e1871a6232ba1655219bf617
8 changes: 8 additions & 0 deletions odata/state.py
Original file line number Diff line number Diff line change
@@ -259,6 +259,14 @@ def _clean_new_entity(self, entity):
else:
if value.__odata__.id:
insert_data['{0}@odata.bind'.format(prop.name)] = value.__odata__.id

# Put the foreign key back into the request for compatibility with
# systems that don't handle {entity} odata.bind correctly
try:
insert_data[prop.foreign_key] = getattr(value, prop.foreign_key)
except:
pass

else:
insert_data[prop.name] = self._clean_new_entity(value)