On May 17, 2012, at 7:05 PM, Demitri Muna wrote: > > On May 17, 2012, at 6:33 PM, Michael Bayer wrote: > >> OK this is way too much verbiage. If the error is as you describe, a bug >> involving reflection of two tables across two schemas, I'd need a test which >> illustrates this alone, no ORM or full database dumps, with a simple failure >> to identify a foreign key constraint between them. I've attached a sample >> of exactly what I'd like to see. >> >> If the issue is not as simple as this, then we will have to dig into >> multiple tables, mappings, etc. but you should be able to reproduce the >> specific case here with just two tables. > > I've refactored the example to the simplest case. We can see if the fix > addresses many-to-many relationships as well.
very nice ! Though Im sorry I put you through this as I just remembered a key caveat with Postgresql, and in fact it's even documented here: http://docs.sqlalchemy.org/en/rel_0_7/dialects/postgresql.html#remote-cross-schema-table-introspection When using cross-schema reflection, you have the option of either using only "public" in your schema search path, or *not* schema-qualifying the tables. This is because when you have the alternate schemas in your search path, Postgresql does not tell SQLAlchemy about the schema name when it returns foreign key information - it returns just the tablename, columnnname, but not the schema. Therefore when you have your Table objects which schema names in them, SQLAlchemy can't match them up and instead makes another Table that you aren't seeing as the target of each cross-schema foreign key, which has no schema name. That's likely what's happening here, evidenced by the fact that your test case works for me (I leave the search path set at its default of "public"). -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
