summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorSebastian Bank <sebastian.bank@uni-leipzig.de>2018-04-02 11:25:08 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-04-03 09:31:07 -0400
commit9f986ce10c6755af3f347a56f9ea03e0e2c5943e (patch)
tree071fbf196fa0a0bbd1af23630e737a35448a0fe4 /lib/sqlalchemy/dialects/postgresql/base.py
parent55371f4cffa730f65f1b687e9f6287d2ac189227 (diff)
downloadsqlalchemy-9f986ce10c6755af3f347a56f9ea03e0e2c5943e.tar.gz
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
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py14
1 files changed, 14 insertions, 0 deletions
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"