]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed two issues regarding Sybase reflection, allowing tables
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 10 Aug 2015 14:07:17 +0000 (10:07 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 10 Aug 2015 14:07:17 +0000 (10:07 -0400)
without primary keys to be reflected as well as ensured that
a SQL statement involved in foreign key detection is pre-fetched up
front to avoid driver issues upon nested queries.  Fixes here
courtesy Eugene Zapolsky; note that we cannot currently test
Sybase to locally verify these changes.
fixes #3508  fixes #3509

doc/build/changelog/changelog_10.rst
lib/sqlalchemy/dialects/sybase/base.py

index 593c26e00108ae2d1c7edd6cfc826010aed2a323..ad9c1473d0200946c0f6ec80dd958d751224d15c 100644 (file)
 .. changelog::
     :version: 1.0.9
 
+    .. change::
+        :tags: bug, sybase
+        :tickets: 3508, 3509
+
+        Fixed two issues regarding Sybase reflection, allowing tables
+        without primary keys to be reflected as well as ensured that
+        a SQL statement involved in foreign key detection is pre-fetched up
+        front to avoid driver issues upon nested queries.  Fixes here
+        courtesy Eugene Zapolsky; note that we cannot currently test
+        Sybase to locally verify these changes.
+
     .. change::
         :tags: bug, postgresql
         :pullreq: github:190
index ae0473a3efcc9946d627f57a3fc4165133348f54..b3f8e307af76f49546cb884acc5902f5910a32b0 100644 (file)
@@ -608,8 +608,8 @@ class SybaseDialect(default.DefaultDialect):
           FROM sysreferences r JOIN sysobjects o on r.tableid = o.id
           WHERE r.tableid = :table_id
         """)
-        referential_constraints = connection.execute(REFCONSTRAINT_SQL,
-                                                     table_id=table_id)
+        referential_constraints = connection.execute(
+            REFCONSTRAINT_SQL, table_id=table_id).fetchall()
 
         REFTABLE_SQL = text("""
           SELECT o.name AS name, u.name AS 'schema'
@@ -740,10 +740,13 @@ class SybaseDialect(default.DefaultDialect):
         results.close()
 
         constrained_columns = []
-        for i in range(1, pks["count"] + 1):
-            constrained_columns.append(pks["pk_%i" % (i,)])
-        return {"constrained_columns": constrained_columns,
-                "name": pks["name"]}
+        if pks:
+            for i in range(1, pks["count"] + 1):
+                constrained_columns.append(pks["pk_%i" % (i,)])
+            return {"constrained_columns": constrained_columns,
+                    "name": pks["name"]}
+        else:
+            return {"constrained_columns": [], "name": None}
 
     @reflection.cache
     def get_schema_names(self, connection, **kw):