-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multi parent relationship for changes #3180
multi parent relationship for changes #3180
Conversation
|
}, | ||
{ | ||
}), | ||
expect.objectContaining({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the tests to expect.objectContaining
to reduce the refactor effort in the future.
FOREIGN KEY(parent_id) REFERENCES change(id), | ||
FOREIGN KEY(child_id) REFERENCES change(id), | ||
-- Prevent self referencing edges | ||
CHECK (parent_id != child_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know CHECK
before. Very cool. SQLite now verifies that edges are not self-referencing. A unit test has been written as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall we used this to validate the id of the entity type. So if you try to insert an change id (here postfixed with the c) "415f1f62-2017-4761-9ece-519c1e5e45e3-c" into a snapshot you can fail early
const parent = await lix.db | ||
.selectFrom("change") | ||
.innerJoin("snapshot", "snapshot.id", "change.snapshot_id") | ||
.selectAll("change") | ||
.select("snapshot.value") | ||
.where("change.id", "=", change.parent_id) | ||
.executeTakeFirstOrThrow(); | ||
|
||
const { rowIndex, columnIndex } = parent.value as unknown as Cell; | ||
(parsed.data as any)[rowIndex][columnIndex] = ""; | ||
// if the row is empty after deleting the cell, remove it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Querying the snapshot is not needed anymore if the entity_id exists on the change itself 😎
// TODO https://github.com/opral/lix-sdk/issues/105 | ||
// .where(isInSimulatedCurrentBranch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the TODOS that should be tackled after the branch milestone.
- branching will influence the logic
- working on this now is a waste of time
if (parentEdges.length > 1) { | ||
// https://github.com/opral/inlang-sdk/issues/134 | ||
throw new Error( | ||
"Unimplemented. Multiple parents not supported until the branch feature exists.", | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the TODOS that should be tackled after the branch milestone.
branching will influence the logic
working on this now is a waste of time
…1-multi-parent-relationship-for-changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIP review - will to look deeper into the helper queries
FOREIGN KEY(parent_id) REFERENCES change(id), | ||
FOREIGN KEY(child_id) REFERENCES change(id), | ||
-- Prevent self referencing edges | ||
CHECK (parent_id != child_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall we used this to validate the id of the entity type. So if you try to insert an change id (here postfixed with the c) "415f1f62-2017-4761-9ece-519c1e5e45e3-c" into a snapshot you can fail early
Closes opral/lix-sdk#98
Changes
change_edges
table to model multi parent relationshipsAdditional information