summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2020-12-07 18:37:29 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-12-08 19:54:05 -0500
commitb71e46f0470964358d44aec08f940260f78691f0 (patch)
tree44c9b5934ad550b4688700e8124204411e42190f /lib/sqlalchemy/dialects/postgresql/base.py
parent18b1b261ff988549e75b011f2f4296fb13b24d64 (diff)
downloadsqlalchemy-b71e46f0470964358d44aec08f940260f78691f0.tar.gz
Implement `TypeEngine.as_generic`
Added :meth:`_types.TypeEngine.as_generic` to map dialect-specific types, such as :class:`sqlalchemy.dialects.mysql.INTEGER`, with the "best match" generic SQLAlchemy type, in this case :class:`_types.Integer`. Pull request courtesy Andrew Hannigan. Abstract away how we check for "overridden methods" so it is more clear what the intent is and that the methodology can be independently tested. Fixes: #5659 Closes: #5714 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5714 Pull-request-sha: 91afb9a0ba3bfa81a1ded80c025989213cf6e4eb Change-Id: Ic54d6690ecc10dc69e6e72856d5620036cea472a
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 612bc9223..e41e489c0 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1474,6 +1474,9 @@ class INTERVAL(sqltypes.NativeForEmulated, sqltypes._AbstractInterval):
def _type_affinity(self):
return sqltypes.Interval
+ def as_generic(self, allow_nulltype=False):
+ return sqltypes.Interval(native=True, second_precision=self.precision)
+
@property
def python_type(self):
return dt.timedelta