]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Removed a 128-character truncation from the reflection of the
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 Oct 2013 23:00:05 +0000 (19:00 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 Oct 2013 23:00:29 +0000 (19:00 -0400)
server default for a column; this code was original from
PG system views which truncated the string for readability.
[ticket:2844]

doc/build/changelog/changelog_08.rst
lib/sqlalchemy/dialects/postgresql/base.py
test/dialect/postgresql/test_reflection.py

index a54f51a3e897416587b8ccc8fd042663d53a31ff..1ac48c7092839c89f0ce251cd9144248e5508f18 100644 (file)
 .. changelog::
     :version: 0.8.3
 
+    .. change::
+        :tags: bug, postgresql
+        :tickets: 2844
+        :versions: 0.9.0
+
+        Removed a 128-character truncation from the reflection of the
+        server default for a column; this code was original from
+        PG system views which truncated the string for readability.
+
     .. change::
         :tags: bug, mysql
         :tickets: 2721, 2839
index b879fb742b2b16b58af08d97279f581f82974342..a20cca702e4a972a0584b69e4d5207951c374e7b 100644 (file)
@@ -1679,8 +1679,7 @@ class PGDialect(default.DefaultDialect):
         SQL_COLS = """
             SELECT a.attname,
               pg_catalog.format_type(a.atttypid, a.atttypmod),
-              (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid)
-                for 128)
+              (SELECT pg_catalog.pg_get_expr(d.adbin, d.adrelid)
                 FROM pg_catalog.pg_attrdef d
                WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum
                AND a.atthasdef)
index d8e4ea3ced6a47d46f68828d51cb4220cc874736..ccb4a48cd4f0a4738948e7e9c8a069d2459caba3 100644 (file)
@@ -159,6 +159,17 @@ class ReflectionTest(fixtures.TestBase):
                         subject.join(referer).onclause))
 
     @testing.provide_metadata
+    def test_reflect_default_over_128_chars(self):
+        Table('t', self.metadata,
+                Column('x', String(200), server_default="abcd" * 40)
+            ).create(testing.db)
+
+        m = MetaData()
+        t = Table('t', m, autoload=True, autoload_with=testing.db)
+        eq_(
+            t.c.x.server_default.arg.text, "'%s'::character varying" % ("abcd" * 40)
+        )
+    @testing.provide_metadata
     def test_renamed_sequence_reflection(self):
         metadata = self.metadata
         t = Table('t', metadata, Column('id', Integer, primary_key=True))