MCPcopy Index your code
hub / github.com/zzzeek/sqlalchemy / has_type

Method has_type

lib/sqlalchemy/dialects/postgresql/base.py:3847–3866  ·  view source on GitHub ↗
(self, connection, type_name, schema=None, **kw)

Source from the content-addressed store, hash-verified

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()

Callers 7

has_typeMethod · 0.45
_can_create_typeMethod · 0.45
_can_drop_typeMethod · 0.45
test_has_typeMethod · 0.45
test_inspect_enumsMethod · 0.45
test_standalone_enumMethod · 0.45

Calls 4

selectFunction · 0.90
whereMethod · 0.45
joinMethod · 0.45
scalarMethod · 0.45

Tested by 4

test_has_typeMethod · 0.36
test_inspect_enumsMethod · 0.36
test_standalone_enumMethod · 0.36