Hello, list.
First off, thanks for storm.
Then, to something that confuses me wildly. I have a table where some
columns are sometimes strings and sometimes ints, so I've declared
them as UNICODE in my CREATE TABLE sql.
I'm having trouble reading that column back, if the value is a number
(all integers). I've attached a test case highlighting my woes, here's
the error message:
TypeError: Expected unicode, found <type 'int'>: 9001
Is this expected behaviour? (I surely didn't expect it... ;)
For the time being I've worked around this issue by prepending a
string to the column before it is flushed, with the
__storm_pre_flush__ hook (see attachment) -- but I'm hoping that I
won't have to in the future.
Take care,
--
Håvard Gulldahl <[EMAIL PROTECTED]>
Telefon: 9971 0615
http://lurtgjort.no/
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import storm.locals as storm
class test(object):
__storm_table__ = 'test'
_sql = """CREATE TABLE test (
id INTEGER PRIMARY KEY,
funk UNICODE); """
id = storm.Int(primary=True)
funk = storm.Unicode()
# remove `WORKAROUND' to work around bug
def WORKAROUND__storm_pre_flush__(self):
self.funk = unicode('str'+str(self.funk))
db = storm.create_database('sqlite:')
print db
store = storm.Store(db)
# create table
store.execute(test._sql)
# make object
myFunkyTest = test()
# funk is all int now, but might also be unicode text strings
myFunkyTest.funk = u'9001'
# commit, populate db
store.add(myFunkyTest)
store.commit()
# forget object
import gc
del myFunkyTest
garbage = gc.collect()
# create havoc
print store.get(test, 1).funk
--
storm mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/storm