sqlalchemy should accept u'3' AND 3 from sqlite db default values

Issue #2265 resolved
Former user created an issue

First, thanks very much to Taavi for helping figure this out.

We were having trouble using meta.reflect() on CentOS with an sqlite db when the same code was running fine on Mac.

What we were trying to run:

self.engine = create_engine(url)
self.scheduler_db_meta = MetaData()
self.scheduler_db_meta.reflect(bind=self.engine)
self.scheduler_db_meta.bind = self.engine

Error: http://pastebin.com/9fF1vQHN

Looks like this is due to libsqlite returning default values differently - on the mac the default value comes back as u'3' instead of 3 (on centos)

STR:

>>> import sqlalchemy
>>> e = sqlalchemy.create_engine('sqlite:///foo.db')
>>> c = e.connect()
>>> r = c.execute('pragma table_info("foo")')
>>> r.fetchall()
[u'an', u'int', 0, u'3', 0)]((0,)
(on the mac)
versus:
[u'an', u'int', 0, 3, 0)]((0,)
(on centos)

This is also a bug on sqlite for not choosing one way to return the values across all OSes but it seems to me like even if they did, sqlalchemy should be prepared to accept either format.

Comments (4)

  1. Mike Bayer repo owner

    missing here is the original table definition you're trying to reflect, else I can't reproduce this.

    Also there was a behavioral change regarding sqlite default reflection that is specifically in 0.7.2 of SQLAlchemy - is this error with SQLAlchemy prior/later to 0.7.2, or both ?

  2. Mike Bayer repo owner
    • changed milestone to 0.7.9

    K, I guess at some point we'll have to try out sqlite on two platforms with a table like this:

    CREATE TABLE test (
      somecol INTEGER DEFAULT '3'
    )
    
  3. Log in to comment