phrr...@googlemail.com wrote:
>
> Hi Mike,
> the situation I am encountering is when the other table is not part of
> the metadata collection i.e. SQLAlchemy doesn't know anything about
> it. It looks like the unit-tests enumerate the tables by calling
> table_names() which causes has_table() and reflecttable() to be called
> in turn. There doesn't appear to be a way of expressing that a table
> is referenced by a foreign key constraint .. from what I can see, the
> various dialects implementation of reflecttable check to see if this
> table references other tables.
I'm not familiar with any test that relies upon that method - every unit
test within SQLA deals with a single MetaData object which contains all
tables, and the foreign key references between those tables are known.
There is an option called "--dropfirst" which does do the table_names()
thing you mention, but that option is only a convenience measure to rerun
the tests on a database that still has tables leftover from a previously
failed run. It also makes usage of foreign keys to drop tables in the
correct order.
Any foreign key constraint is represented in a Table object using the
ForeignKey() or ForeignKeyConstraint() object. When tables are loaded via
reflecttable(), the tables are all loaded into a single MetaData object,
and the foreign keys are reflected into ForeignKey objects, and the drop
in order of dependency works in all cases. So I don't know what you mean
by "there doesn't appear to be a way of expressing that a table is
referenced by a foreign key constraint".
>