Skip to content

Commit

Permalink
dont add None values in the store of objects in migration import func…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
afourmy committed Jul 6, 2023
1 parent 1822495 commit 5eebffa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions eNMS/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,16 +1014,20 @@ def migration_import(self, folder="migrations", **kwargs):
sql_value = []
for name in value:
if name not in store[relation["model"]]:
store[relation["model"]][name] = db.fetch(
related_instance = db.fetch(
relation["model"], name=name, allow_none=True
)
if store[relation["model"]][name]:
if related_instance:
store[relation["model"]][name] = related_instance
if name in store[relation["model"]]:
sql_value.append(store[relation["model"]][name])
else:
if value not in store[relation["model"]]:
store[relation["model"]][value] = db.fetch(
related_instance = db.fetch(
relation["model"], name=value, allow_none=True
)
if related_instance:
store[relation["model"]][value] = related_instance
sql_value = store[relation["model"]][value]
try:
setattr(store[model].get(instance_name), property, sql_value)
Expand Down

0 comments on commit 5eebffa

Please sign in to comment.