Skip to content

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

Closed

Description

@cpcloud

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.

Activity

  1. cpcloud commented on Sep 4, 2015

    @cpcloud
    ContributorAuthor

    This was introduced in 1b911f2

  2. cpcloud commented on Sep 4, 2015

    @cpcloud
    ContributorAuthor

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

  3. graingert commented on Sep 4, 2015

    @graingert
    Member

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

  4. cpcloud commented on Sep 4, 2015

    @cpcloud
    ContributorAuthor

    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.

  5. cpcloud commented on Sep 4, 2015

    @cpcloud
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions