Skip to content

Commit

Permalink
delete relations that were deleted from a resource-instance dt tile, re
Browse files Browse the repository at this point in the history
  • Loading branch information
whatisgalen committed Feb 10, 2025
1 parent 579c18f commit 25ce71d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions arches/app/datatypes/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2094,14 +2094,26 @@ def pre_tile_save(self, tile, nodeid):

def post_tile_save(self, tile, nodeid, request):
ret = False
sql = """
create_sql = """
SELECT * FROM __arches_create_resource_x_resource_relationships('%s') as t;
""" % (
tile.pk
)
delete_sql = """
DELETE FROM resource_x_resource WHERE tileid = '%s' AND resourcexid NOT IN (%s);
""" % (
tile.pk,
",".join(
[
"'%s'" % relationship["resourceXresourceId"]
for relationship in tile.data[nodeid]
]
),
)

with connection.cursor() as cursor:
cursor.execute(sql)
cursor.execute(delete_sql)
cursor.execute(create_sql)
ret = cursor.fetchone()
return ret

Expand Down

0 comments on commit 25ce71d

Please sign in to comment.