| 3845 | |
| 3846 | @reflection.cache |
| 3847 | def has_type(self, connection, type_name, schema=None, **kw): |
| 3848 | query = ( |
| 3849 | select(pg_catalog.pg_type.c.typname) |
| 3850 | .join( |
| 3851 | pg_catalog.pg_namespace, |
| 3852 | pg_catalog.pg_namespace.c.oid |
| 3853 | == pg_catalog.pg_type.c.typnamespace, |
| 3854 | ) |
| 3855 | .where(pg_catalog.pg_type.c.typname == type_name) |
| 3856 | ) |
| 3857 | if schema is None: |
| 3858 | query = query.where( |
| 3859 | pg_catalog.pg_type_is_visible(pg_catalog.pg_type.c.oid), |
| 3860 | # ignore pg_catalog schema |
| 3861 | pg_catalog.pg_namespace.c.nspname != "pg_catalog", |
| 3862 | ) |
| 3863 | elif schema != "*": |
| 3864 | query = query.where(pg_catalog.pg_namespace.c.nspname == schema) |
| 3865 | |
| 3866 | return bool(connection.scalar(query)) |
| 3867 | |
| 3868 | def _get_server_version_info(self, connection): |
| 3869 | v = connection.exec_driver_sql("select pg_catalog.version()").scalar() |