diff --git a/includes/referential_integrity_assertions.js b/includes/referential_integrity_assertions.js index 1c06601..6572f13 100644 --- a/includes/referential_integrity_assertions.js +++ b/includes/referential_integrity_assertions.js @@ -25,7 +25,7 @@ const assertions = []; const createReferentialIntegrityAssertion = (globalParams, parentSchema, parentTable, parentKey, parentFilter, childSchema, childTable, childKey, childFilter) => { - const assertion = assert(`assert_referential_integrity_${parentSchema}_${parentTable}_${childSchema}_${childTable}`) + const assertion = assert(`assert_referential_integrity_${parentSchema}_${parentTable}_${parentKey}_${childSchema}_${childTable}_${childKey}`) .database(globalParams.database) .schema(globalParams.schema) .description(`Check referential integrity for ${childTable}.${childKey} referencing ${parentTable}.${parentKey}`) @@ -52,8 +52,8 @@ const createReferentialIntegrityAssertion = (globalParams, parentSchema, parentT SELECT pt.${parentKey} FROM parent_filtering AS pt - LEFT JOIN child_filtering AS t ON t.${childKey} = pt.${parentKey} - WHERE t.${childKey} IS NULL + RIGHT JOIN child_filtering AS t ON t.${childKey} = pt.${parentKey} + WHERE pt.${parentKey} IS NULL `); (globalParams.tags && globalParams.tags.forEach((tag) => assertion.tags(tag)));