datajoint-python icon indicating copy to clipboard operation
datajoint-python copied to clipboard

Warn user if access error is encountered during table declaration

Open christoph-blessing opened this issue 5 years ago • 2 comments
trafficstars

Currently the AccessError catched here is silent meaning the user has no indication it was raised in the first place. This silent error can cause other errors down the line which are harder to debug than they need to be due to the user not being aware of their root cause. Therefore I propose to display a warning to the user if an AccessError is encountered instead of just pass.

christoph-blessing avatar Aug 07 '20 15:08 christoph-blessing

This occurs when users do not have a CREATE privilege and simply use an existing database. This is a very common scenario when the code is distributed for an existing database. In those cases, quietly skipping the failed creation is the right course of action. Perhaps one way to solve it is to provide clearer diagnostics for when the table remains underclared and the user attempts to use it.

dimitri-yatsenko avatar Aug 07 '20 16:08 dimitri-yatsenko

In my case it occurred because I did not have the REFERENCES privilege for a foreign key in the table I was trying to create.

Could something like the following work?

except AccessError:
    if not self.is_declared:
        raise

christoph-blessing avatar Aug 10 '20 08:08 christoph-blessing