-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from Digital-Engineering/development
Development
- Loading branch information
Showing
12 changed files
with
370 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/data_access_layer/migrations/059_node_insert_trigger_rewrite.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
CREATE OR REPLACE FUNCTION node_insert_trigger() RETURNS TRIGGER AS $$ | ||
DECLARE | ||
old_id bigint; | ||
old_properties jsonb; | ||
BEGIN | ||
IF NEW.original_data_id IS NOT NULL THEN | ||
BEGIN | ||
SELECT nodes.id, nodes.properties | ||
INTO old_id, old_properties | ||
FROM nodes | ||
WHERE original_data_id = NEW.original_data_id | ||
AND metatype_id = NEW.metatype_id | ||
AND data_source_id = NEW.data_source_id LIMIT 1; | ||
EXCEPTION | ||
WHEN NO_DATA_FOUND THEN | ||
old_id := NULL; | ||
END; | ||
|
||
IF old_id IS NOT NULL THEN | ||
NEW.id = old_id; | ||
/* | ||
if the old properties are exactly the same as the new properties, silently discard the insert | ||
*/ | ||
IF old_properties IS NOT DISTINCT FROM NEW.properties THEN | ||
RETURN NULL; | ||
END IF; | ||
END IF; | ||
END IF; | ||
|
||
RETURN NEW; | ||
END; | ||
$$ language plpgsql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters