Skip to content

Commit

Permalink
Include related objects when searching for the matching duplicate
Browse files Browse the repository at this point in the history
object rather then getting the same object again later.
  • Loading branch information
RKrahl committed Nov 6, 2015
1 parent ecb8cc5 commit 8788835
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions icatingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def check_duplicate(obj):
# Allow IGNORE, CHECK, and OVERWRITE only on single objects
for r in obj.InstMRel:
if getattr(obj, r):
raise RuntimeError("Cannot %s duplicate on %s if %s is not empty."
% (conf.duplicate, obj.BeanName, r))
dobj = client.searchMatching(obj)
raise ValueError("Cannot %s duplicate on %s if %s is not empty."
% (conf.duplicate, obj.BeanName, r))
dobj = client.searchMatching(obj, includes="1")
if conf.duplicate == "IGNORE":
pass
elif conf.duplicate == "CHECK":
Expand All @@ -99,7 +99,6 @@ def check_duplicate(obj):
if v is not None and getattr(dobj, a) != v:
raise
elif conf.duplicate == "OVERWRITE":
dobj.get()
for a in obj.InstAttr:
v = getattr(obj, a)
if v is not None:
Expand Down

0 comments on commit 8788835

Please sign in to comment.