Skip to content

Commit 67899cb

Browse files
authored
Merge pull request #1 from jonnerd154/feature/support_foreign_key_without_bind
Include Foreign Key in requests
2 parents 39a90ac + 9f89d92 commit 67899cb

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

odata/state.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ def _clean_new_entity(self, entity):
259259
else:
260260
if value.__odata__.id:
261261
insert_data['{0}@odata.bind'.format(prop.name)] = value.__odata__.id
262+
263+
# Put the foreign key back into the request for compatibility with
264+
# systems that don't handle {entity} odata.bind correctly
265+
try:
266+
insert_data[prop.foreign_key] = getattr(value, prop.foreign_key)
267+
except:
268+
pass
269+
262270
else:
263271
insert_data[prop.name] = self._clean_new_entity(value)
264272

0 commit comments

Comments
 (0)