Skip to content

Commit

Permalink
Don't pop the FK values
Browse files Browse the repository at this point in the history
  • Loading branch information
suhrawardi committed Apr 7, 2021
1 parent 3a4553b commit 38ee446
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion odata/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def execute_get(self, url, params=None):
self.log.info(u'Closed GET response for {0}'.format(url))

def execute_post(self, url, data, params=None):
self.log.info(u'DATA: {0}'.format(data))
try:
response = None
headers = {
Expand Down
1 change: 0 additions & 1 deletion odata/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def _insert_new(self, entity):

es = entity.__odata__
insert_data = es.data_for_insert()
self.log.info(u'DATA FOR INSERT: {0}'.format(data))
saved_data = self.connection.execute_post(url, insert_data)
es.reset()
es.connection = self.connection
Expand Down
8 changes: 5 additions & 3 deletions odata/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
from __future__ import print_function
import os
import inspect
import logging
import re
from collections import OrderedDict

from odata.property import PropertyBase, NavigationProperty
import odata


class EntityState(object):

def __init__(self, entity):
self.log = logging.getLogger('odata.state')
""":type entity: EntityBase """
self.entity = entity
self.dirty = []
Expand Down Expand Up @@ -173,6 +176,7 @@ def _clean_new_entity(self, entity):
insert_data['@odata.type'] = entity.__odata_type__

es = entity.__odata__

for _, prop in es.properties:
if prop.is_computed_value:
continue
Expand All @@ -186,8 +190,6 @@ def _clean_new_entity(self, entity):

# Deep insert from nav properties
for prop_name, prop in es.navigation_properties:
if prop.foreign_key:
insert_data.pop(prop.foreign_key, None)

value = getattr(entity, prop_name, None)
""":type : None | odata.entity.EntityBase | list[odata.entity.EntityBase]"""
Expand All @@ -213,7 +215,7 @@ def _clean_new_entity(self, entity):
else:
if value.__odata__.id:
insert_data['{0}@odata.bind'.format(prop.name)] = value.__odata__.id
else:
elif isinstance(value, odata.entity.EntityBase):
insert_data[prop.name] = self._clean_new_entity(value)

for _, prop in es.properties:
Expand Down

0 comments on commit 38ee446

Please sign in to comment.