Last active
August 11, 2019 07:37
-
-
Save dadair-ca/f9d9dcfcdfbfacf9bf5f17094560d647 to your computer and use it in GitHub Desktop.
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
WITH inserted AS ( | |
SELECT fhir_create_resource(:resource) AS resource -- should end up inserting into `encounter` table | |
), joined_foo AS ( | |
INSERT INTO foo(x) SELECT resource->'id' FROM inserted | |
RETURNING * | |
), joined_bar AS ( | |
INSERT INTO bar(x) SELECT resource->'id' FROM inserted | |
RETURNING * | |
) SELECT resource FROM inserted; | |
-- foo.x references encounter(id) | |
-- bar.x references encounter(id) | |
-- query complains that insert into foo(x) and bar(x) fails with foreign key violation (encounter record not in encounter table) | |
-- which seems to suggest that the `SELECT fhir_create_resource(:resource) AS resource` isn't actually inserting into the `encounter` table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment