From: Mike Bayer Date: Fri, 28 Jun 2013 15:49:41 +0000 (-0400) Subject: Type lookup when reflecting the Firebird types LONG and X-Git-Tag: rel_0_8_2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f57fc6836f47598362247045c296c5b2c0182b6d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git 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] Conflicts: doc/build/changelog/changelog_09.rst --- 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/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py index 95196f44c4..682d209855 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'):