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

Comments

Projects
None yet
2 participants
@cpcloud
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

This comment has been minimized.

Show comment
Hide comment
@cpcloud

cpcloud Sep 4, 2015

Contributor

This was introduced in 1b911f2

Contributor

cpcloud commented Sep 4, 2015

This was introduced in 1b911f2

@cpcloud

This comment has been minimized.

Show comment
Hide comment
@cpcloud

cpcloud Sep 4, 2015

Contributor

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

Contributor

cpcloud commented Sep 4, 2015

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

@graingert

This comment has been minimized.

Show comment
Hide comment
@graingert

graingert Sep 4, 2015

Collaborator

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

Collaborator

graingert commented Sep 4, 2015

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

@cpcloud

This comment has been minimized.

Show comment
Hide comment
@cpcloud

cpcloud Sep 4, 2015

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@cpcloud

cpcloud Sep 4, 2015

Contributor

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

Contributor

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