Skip to content

Commit 31accd6

Browse files
authored
BE-240: Fix foreign key violation check and sort entity type allOf array (#8185)
1 parent ecb4d93 commit 31accd6

File tree

2 files changed

+4
-3
lines changed
  • libs/@local/graph/postgres-store/src/permissions
  • tests/hash-backend-integration/src/tests/graph/ontology/primitive

2 files changed

+4
-3
lines changed

libs/@local/graph/postgres-store/src/permissions/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,9 +1165,7 @@ where
11651165
.await
11661166
.map_err(|error| {
11671167
let policy_error = match error.code() {
1168-
Some(&SqlState::FOREIGN_KEY_VIOLATION) => {
1169-
ActionError::HasChildren { id: action }
1170-
}
1168+
Some(&SqlState::RESTRICT_VIOLATION) => ActionError::HasChildren { id: action },
11711169
_ => ActionError::StoreError,
11721170
};
11731171
Report::new(error).change_context(policy_error)

tests/hash-backend-integration/src/tests/graph/ontology/primitive/entity-type.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ describe("Entity type CRU", () => {
372372
],
373373
);
374374

375+
closedMultiEntityType.allOf.sort((a, b) => a.$id.localeCompare(b.$id));
376+
375377
// It's not specified how `required` is ordered, so we need to sort it before comparing
376378
if (closedMultiEntityType.required) {
377379
closedMultiEntityType.required.sort();
@@ -389,6 +391,7 @@ describe("Entity type CRU", () => {
389391
),
390392
);
391393
assert(allOf !== undefined);
394+
allOf.sort((a, b) => a.$id.localeCompare(b.$id));
392395

393396
expect(closedMultiEntityType).toEqual({
394397
allOf,

0 commit comments

Comments
 (0)