project-m36
project-m36 copied to clipboard
can't `undefine` a relation if there is a constraint
TutorialD (master/main): x:=relation{tuple{name "wow"}}
TutorialD (master/main): key unique_name_x {name} x
TutorialD (master/main): undefine x
ERR: RelVarNotDefinedError "x"
Is it because the unique_name_x
constraint must be deleted first? If so, how can that be done?
(also let me know if I'm posting too much and this is becoming a burden)
It looks like you've identified the cause, but the error could definitely be improved. In this case, the constraint-checking mechanism is complaining that it can't find the required "x" relvar since you tried to remove it.
Don't worry about reporting bugs. They are all valuable!
dug around the source code a bit. The way to fix this issue is deleteconstraint unique_name_x
before undefine x
. Perhaps docs need to be updated or some sort of cascading behavior is desired?
I think you are right that, at the very least, the error message when a relvar referenced by a constraint is deleted should be improved.
This is fixed on 346_incdep_errors
. It now looks like:
TutorialD (master/main): x:=relation{tuple{name "wow"}}
TutorialD (master/main): key unique_name_x {name} x
TutorialD (master/main): undefine x
ERR: InclusionDependencyCheckError "unique_name_x" (Just (RelVarNotDefinedError "x"))
Does this provide sufficient context to the user?
What does "Just" mean in this scenario? Does it mean the constraint is only used by the relation "x"?
No, it means that the inclusion dependency error may also not have an additional context- it's a Haskell thing.
One thing on my to-do list is to improve errors across-the-board to provide better context and present a human-readable form (instead of just printing the Haskell ADT).