Package: python-sqlalchemy
Version: 0.7.8-1.1
Severity: normal
Tags: upstream patch

The description I submitted upstream:

  The firebird backend translates Firebird's types incorrectly.

  Firstly, a firebird LONG is 32 bits, a INT64 is 64 bigs. Secondly,
  all firebird integer types have a precision and scale. If they
  are 0 the raw type can be used, otherwise NUMERIC must be used.

  The attached patch fixes the problem. The patch is for 0.7.8, but
  master looks the same.

-- System Information:
Debian Release: 7.0
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'stable-updates'), (50, 'testing'), (40, 
'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages python-sqlalchemy depends on:
ii  python  2.7.3-4

Versions of packages python-sqlalchemy recommends:
ii  python-sqlalchemy-ext  0.7.8-1.1

Versions of packages python-sqlalchemy suggests:
ii  python-kinterbasdb     3.3.0-3
pn  python-mysqldb         <none>
pn  python-psycopg2        <none>
pn  python-pymssql         <none>
ii  python-sqlalchemy-doc  0.7.8-1.1

-- no debconf information
Description: Fix mapping of firebird types
 Firebird integer types can be either the raw type or NUMERIC,
 depending on whether they have a precision and scale.
Author: Russell Stuart <[email protected]>
Bug: http://www.sqlalchemy.org/trac/ticket/2757
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/lib/sqlalchemy/dialects/firebird/base.py
+++ b/lib/sqlalchemy/dialects/firebird/base.py
@@ -69,7 +69,7 @@
 
 """
 
-import datetime, re
+import datetime, inspect, re
 
 from sqlalchemy import schema as sa_schema
 from sqlalchemy import exc, types as sqltypes, sql, util
@@ -78,9 +78,8 @@
 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([
@@ -149,13 +148,13 @@
 
 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,
@@ -561,8 +560,8 @@
                 util.warn("Did not recognize type '%s' of column '%s'" %
                           (colspec, name))
                 coltype = sqltypes.NULLTYPE
-            elif colspec == 'INT64':
-                coltype = coltype(
+            elif Integer in inspect.getmro(coltype) and row['fprec'] != 0:
+                coltype = NUMERIC(
                                 precision=row['fprec'], 
                                 scale=row['fscale'] * -1)
             elif colspec in ('VARYING', 'CSTRING'):

Reply via email to