project-m36 icon indicating copy to clipboard operation
project-m36 copied to clipboard

can't `undefine` a relation if there is a constraint

Open boogerlad opened this issue 2 years ago • 3 comments

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)

boogerlad avatar Apr 24 '22 18:04 boogerlad

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!

agentm avatar Apr 24 '22 22:04 agentm

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?

boogerlad avatar Apr 24 '22 23:04 boogerlad

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.

agentm avatar Apr 25 '22 03:04 agentm

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?

agentm avatar Oct 03 '22 16:10 agentm

What does "Just" mean in this scenario? Does it mean the constraint is only used by the relation "x"?

boogerlad avatar Oct 03 '22 17:10 boogerlad

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).

agentm avatar Oct 05 '22 14:10 agentm