create_object should not add an ID if not present in the DB model
Change I192793aa433606a1508f24564c54164f961018d9 introduced a way to handle DB objects that don't have 'id' as primary field. Anyway create_object should be modified not to add the 'id' field if not present in the model. Change-Id: I14e4e32255caf9244ff2793aef142b1a6fa57de3
This commit is contained in:
parent
8202954e10
commit
3eaa3e627e
@ -107,7 +107,7 @@ def get_objects(context, model, **kwargs):
|
||||
|
||||
def create_object(context, model, values):
|
||||
with context.session.begin(subtransactions=True):
|
||||
if 'id' not in values:
|
||||
if 'id' not in values and hasattr(model, 'id'):
|
||||
values['id'] = uuidutils.generate_uuid()
|
||||
db_obj = model(**values)
|
||||
context.session.add(db_obj)
|
||||
|
Loading…
x
Reference in New Issue
Block a user