zzzeek/sqlalchemy — pull request #128 by rclmenezes (2014-08-14 21:38:49+00:00)
Title: Feature/postgres relkind

First run at fixing https://bitbucket.org/zzzeek/sqlalchemy/issue/2891/support-materialized-views-in-postgresql#comment-11769903

- Tables now take the postresql_relkind parameter in their constructor. This reflection option gets passed to get_table_oid() to filter its search for table oids. Can be full names (e.g. "materialized", "foreign", "view") or short-hand ("m", "f", "v", "r").

- get_table_oid() also always searches through tables with 'v' for backwards compatibility... Any better ideas on how to handle this?

- Added some basic tests for 'm' and 'f' relkinds. Added the postgres_test_db_link configuration for testing.

Another question: All calls to get_table_oid() need to come with table.dialect_kwargs to pass postgresql_relkind. Unfortunately, I couldn't find a way to reference table.dialect_kwargs from the get_unique_constraints method of the Inspector class. Any ideas on how to solve this?

https://github.com/rclmenezes/sqlalchemy/blob/feature/postgres-relkind/lib/sqlalchemy/engine/reflection.py#L385