From 9f986ce10c6755af3f347a56f9ea03e0e2c5943e Mon Sep 17 00:00:00 2001 From: Sebastian Bank Date: Mon, 2 Apr 2018 11:25:08 -0400 Subject: Add postgresl.REGCLASS type for casting table names to OIDs and vice versa Fixes: #4160 Change-Id: Id0bdbad1be3a0950dc8f35895ee13d9264244722 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/435 --- lib/sqlalchemy/dialects/postgresql/base.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/sqlalchemy/dialects/postgresql/base.py') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 1dffe8db9..c5b0db6ce 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1000,6 +1000,16 @@ class OID(sqltypes.TypeEngine): __visit_name__ = "OID" +class REGCLASS(sqltypes.TypeEngine): + + """Provide the PostgreSQL REGCLASS type. + + .. versionadded:: 1.2.7 + + """ + __visit_name__ = "REGCLASS" + + class TIMESTAMP(sqltypes.TIMESTAMP): def __init__(self, timezone=False, precision=None): @@ -1382,6 +1392,7 @@ ischema_names = { 'macaddr': MACADDR, 'money': MONEY, 'oid': OID, + 'regclass': REGCLASS, 'double precision': DOUBLE_PRECISION, 'timestamp': TIMESTAMP, 'timestamp with time zone': TIMESTAMP, @@ -1876,6 +1887,9 @@ class PGTypeCompiler(compiler.GenericTypeCompiler): def visit_OID(self, type_, **kw): return "OID" + def visit_REGCLASS(self, type_, **kw): + return "REGCLASS" + def visit_FLOAT(self, type_, **kw): if not type_.precision: return "FLOAT" -- cgit v1.2.1