From bccf8ff5b1b17fd093308b40e726051256ec14ae Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 28 Jun 2013 11:49:41 -0400 Subject: [PATCH] Type lookup when reflecting the Firebird types LONG and INT64 has been fixed so that LONG is treated as INTEGER, INT64 treated as BIGINT, unless the type has a "precision" in which case it's treated as NUMERIC. Patch courtesy Russell Stuart. [ticket:2757] --- doc/build/changelog/changelog_08.rst | 10 ++++++++++ doc/build/changelog/changelog_09.rst | 10 ++++++++++ lib/sqlalchemy/dialects/firebird/base.py | 13 ++++++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index 625b72c0b7..79f2ce7381 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,16 @@ .. changelog:: :version: 0.8.2 + .. change:: + :tags: bug, firebird + :tickets: 2757 + + Type lookup when reflecting the Firebird types LONG and + INT64 has been fixed so that LONG is treated as INTEGER, + INT64 treated as BIGINT, unless the type has a "precision" + in which case it's treated as NUMERIC. Patch courtesy + Russell Stuart. + .. change:: :tags: bug, postgresql :tickets: 2766 diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 85fd69d8d1..9051327363 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -6,6 +6,16 @@ .. changelog:: :version: 0.9.0 + .. change:: + :tags: bug, firebird + :tickets: 2757 + + Type lookup when reflecting the Firebird types LONG and + INT64 has been fixed so that LONG is treated as INTEGER, + INT64 treated as BIGINT, unless the type has a "precision" + in which case it's treated as NUMERIC. Patch courtesy + Russell Stuart. Also in 0.8.2. + .. change:: :tags: bug, postgresql :tickets: 2766 diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py index bb60a591ea..ab832178eb 100644 --- a/lib/sqlalchemy/dialects/firebird/base.py +++ b/lib/sqlalchemy/dialects/firebird/base.py @@ -78,9 +78,8 @@ from sqlalchemy.engine import base, default, reflection from sqlalchemy.sql import compiler -from sqlalchemy.types import (BIGINT, BLOB, BOOLEAN, DATE, - FLOAT, INTEGER, NUMERIC, SMALLINT, - TEXT, TIME, TIMESTAMP) +from sqlalchemy.types import (BIGINT, BLOB, DATE, FLOAT, INTEGER, NUMERIC, + SMALLINT, TEXT, TIME, TIMESTAMP, Integer) RESERVED_WORDS = set([ @@ -162,13 +161,13 @@ colspecs = { ischema_names = { 'SHORT': SMALLINT, - 'LONG': BIGINT, + 'LONG': INTEGER, 'QUAD': FLOAT, 'FLOAT': FLOAT, 'DATE': DATE, 'TIME': TIME, 'TEXT': TEXT, - 'INT64': NUMERIC, + 'INT64': BIGINT, 'DOUBLE': FLOAT, 'TIMESTAMP': TIMESTAMP, 'VARYING': VARCHAR, @@ -593,8 +592,8 @@ class FBDialect(default.DefaultDialect): util.warn("Did not recognize type '%s' of column '%s'" % (colspec, name)) coltype = sqltypes.NULLTYPE - elif colspec == 'INT64': - coltype = coltype( + elif issubclass(coltype, Integer) and row['fprec'] != 0: + coltype = NUMERIC( precision=row['fprec'], scale=row['fscale'] * -1) elif colspec in ('VARYING', 'CSTRING'): -- 2.47.3