postgresql timestamps and intervals can have precision too

Issue #997 resolved
Former user created an issue

match and strip "(\d+)" anywhere in type string, not just at the end

Index: lib/sqlalchemy/databases/postgres.py
===================================================================
--- lib/sqlalchemy/databases/postgres.py        (revision 4337)
+++ lib/sqlalchemy/databases/postgres.py        (working copy)
@@ -467,8 +467,8 @@
             if include_columns and name not in include_columns:
                 continue

-            ## strip (30) from character varying(30)
-            attype = re.search('([^\([](^\([)+)', format_type).group(1)
+            ## strip (5) from character varying(5), timestamp(5) with time zone, etc
+            attype = re.sub('\([\d,](\d,)+\)', '', format_type)
             nullable = not notnull
             is_array = format_type.endswith('[
@@ -492,6 +492,9 @@
                 numericprec, numericscale = (32, 0)
                 charlen = False

+            if 'timestamp' in attype or 'interval' in attype:
+                charlen = False
+
             args = [](]')
)
             for a in (charlen, numericprec, numericscale):
                 if a is None:

Comments (4)

  1. Mike Bayer repo owner
    • changed milestone to 0.6.1

    PG dialect in 0.6 has "precision" fully supported for interval. its a small change to have it work for timestamp as well.

  2. Log in to comment