diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-08-10 10:07:17 -0400 |
---|---|---|
committer | Stefan Urbanek <stefan@agentfarms.net> | 2015-08-25 23:56:10 -0700 |
commit | 075bb422d51d5fc0a02781a2fcfd4f0e584ec220 (patch) | |
tree | 4ce9b9f518d968dd5bff330dfc4aefb53881288b | |
parent | bf63607b41ff689c68902266c5c62aff8b901629 (diff) | |
download | sqlalchemy-075bb422d51d5fc0a02781a2fcfd4f0e584ec220.tar.gz |
- 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.
fixes #3508 fixes #3509
-rw-r--r-- | doc/build/changelog/changelog_10.rst | 11 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/sybase/base.py | 15 |
2 files changed, 20 insertions, 6 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst index 593c26e00..ad9c1473d 100644 --- a/doc/build/changelog/changelog_10.rst +++ b/doc/build/changelog/changelog_10.rst @@ -19,6 +19,17 @@ :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 diff --git a/lib/sqlalchemy/dialects/sybase/base.py b/lib/sqlalchemy/dialects/sybase/base.py index ae0473a3e..b3f8e307a 100644 --- a/lib/sqlalchemy/dialects/sybase/base.py +++ b/lib/sqlalchemy/dialects/sybase/base.py @@ -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): |