agentm / project-m36

Project: M36 Relational Algebra Engine
The Unlicense
892 stars 48 forks source link

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

Closed boogerlad closed 1 year ago

boogerlad commented 2 years ago
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)

agentm commented 2 years ago

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!

boogerlad commented 2 years ago

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?

agentm commented 2 years ago

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 commented 1 year ago

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?

boogerlad commented 1 year ago

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

agentm commented 1 year ago

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