lib: one cascade graph for every store - #68
Draft
aberoham wants to merge 1 commit into
Draft
Conversation
Which children a hard delete takes with it was decided separately in each backend. mysql has each of them from a FOREIGN KEY; the file stores have no constraints and never implemented them, so destroying a group left its nameservers behind, destroying a user left its sessions, and destroying a zone left its records. references.js names those three edges once. The file stores call cascade() from destroy(), mysql goes on getting it from the constraints, and references.test.js holds whichever store is configured to the same graph. Each case seeds a second parent whose child must survive, so a store that takes too much fails as loudly as one that takes too little. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014AUjj218gbhUHLi7kvDPtd
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Destroy a group on json or toml and its nameservers stay behind. Same for a
user's sessions and a zone's records. mysql removes all three, because it has a
constraint and the file stores have nothing.
Measured on 96f4799 through
lib/<entity>/index.js, one fixture per pair:nt_nameserver_ibfk_1nt_user_session_ibfk_1nt_zone_record_ibfk_1Each backend decided this on its own: mysql reads it off a FOREIGN KEY, the file
stores never implemented it. Their
destroy()is the whole story — filter ownarray, save, return; group, user and zone are the same method over a different
array.
references.jssays the rule once and both sides follow it: the file stores callcascade()fromdestroy(), mysql goes on using its constraints.references.test.jsholds whichever store is configured to that onedeclaration, and doubles as the repro. Every case seeds a second parent whose
child has to survive, so taking too much fails as loudly as taking too little,
and
viabuilds the fixture, so a wrong field name fails too.Watch how you check this. mysql reads a session through its user
(
session/store/mysql.jsjoinsnt_useronu.deleted=0), so a session thatsurvived still reads as absent once the user is gone. Each doomed child is
deleted a second time and has to report there was nothing left.
Verified on mysql, json and toml — targeted green,
./test/run.shgreen, noskips or todos. Three negative checks, each run: drop a
cascade()call and thatedge fails; drop the soft-deleted pass and nameserver and zone_record fail; save
the parent before cascading and the retry case fails.
Draft until #61 lands: it edits three files #61 rewrites, and #61 adds a fourth
edge. Measured there at
e4bd365— after destroying the group,Delegation.delete({gid, oid, type})returnstrueon json, meaning the row wasstill there, and
nullon mysql. Itsdelete()takes the whole triple, so theno-destroy branch in
cascade()needs work rather than one more line in thedeclaration.