autoloading gives misleading error message when table doesn't exist

Issue #138 resolved
Former user created an issue
sqlalchemy.exceptions.ArgumentError: Table event has no primary key columns. Specify primary_key argument to mapper.

I'm going to tag this as postgres-only because I'm not sure. I'll have a look later, and try to fix it.

Comments (7)

  1. Former user Account Deleted

    Bah. Let's talk about how to do a proper report, shall we? It might have been important to mention the use of Mapper() in the original report, for example.

    I've confirmed that Table("not_there", BoundMetaData, autoload=True) gives no errors. But any subsequent use of select(), for example, does an "SELECT FROM not_there": note the lack of fields in the SELECT; I guess this means that .select() expects that Table() has columns :-).

    This whole thing started in 0.1 with .reflecttable() using the "columns for table X" Table() in information_schema: so if the table didn't exist, no columns were found. I haven't checked 0.2, but I'll assume the algorithm is the same, for now.

    There's a "list of tables" Table in information_schema, and the has_table() #31 is implemented. I'll create an has_table() in information_schema and raise an exception there when autoloading. I can't submit the patch yet, as I can't seem to make the unittest fail when it should.

  2. Mike Bayer repo owner
    • assigned issue to
    • marked as major

    my regard for information_schema gets lower every day: #60, #71 . ive proposed on the list to drop the usage of information schema for reflection altogether (and probably, id move the entire "information_schema" module into the extensions package as it seems to be more or less pointless for real-world usage).

  3. Mike Bayer repo owner

    it doesnt quite work for MySQL, since MySQL is using describe and throws its own exception anyway. but for sqlite/postgres it works, still need to test mssql/oracle/firebird but since they are all row-based it should work there too, changeset:1589

  4. Log in to comment