Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflection should raise the proper Exception type when things are not found #38

Closed
cpcloud opened this issue Sep 4, 2015 · 5 comments · Fixed by #39
Closed

Reflection should raise the proper Exception type when things are not found #38

cpcloud opened this issue Sep 4, 2015 · 5 comments · Fixed by #39

Comments

@cpcloud
Copy link
Contributor

cpcloud commented Sep 4, 2015

Right now, when reflection fails, it's usually with a KeyError, but the other sqlalchemy dialects raise sa.exc.NoSuch<object>Error. I have code that depends on this exception being raised, which is how I found this issue.

I've got a PR in the works.

@cpcloud
Copy link
Contributor Author

cpcloud commented Sep 4, 2015

This was introduced in 1b911f2

@cpcloud
Copy link
Contributor Author

cpcloud commented Sep 4, 2015

It looks like only sa.exc.NoSuchTableError is relevant during reflection

@graingert
Copy link
Member

Ah nice catch! Do you have the docs for this?

@cpcloud
Copy link
Contributor Author

cpcloud commented Sep 4, 2015

There's the docs for the exception: http://docs.sqlalchemy.org/en/rel_1_0/core/exceptions.html?highlight=nosuchtableerror#sqlalchemy.exc.NoSuchTableError

I'm looking for the usage docs (if any) right now.

@cpcloud
Copy link
Contributor Author

cpcloud commented Sep 4, 2015

I don't see anything here explicitly stating what exceptions should be raised in the case of not finding tables: http://docs.sqlalchemy.org/en/rel_1_0/core/reflection.html

I grepped through sqlalchemy core and found that indeed sybase, postgresql, and mysql all raise NoSuchTableError for specific functions (postgres has a get_table_oid method that raises it, mysql raises when doing a show create table or describe mytable statements, sybase has a similar mechanism to postgres).

For other dialects I think the error is raised here (in the Inspector class):

https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/engine/reflection.py#L570-L571

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants