[storm] can't select strings outside of storm

Jean Daniel jeandaniel.browne at gmail.com
Thu Oct 30 22:44:41 GMT 2008


Hello,

I have created an object instance persisted with storm in a sqlite
database. The object have a raw string attribute. Outside of
python/storm, in the sqlite3 console, I cannot select the rows on a
specific value. The database was created outside of storm.

I created an instance of the "toto" object with a "titi" string
attribute persisted in the "toto" table. I created the instance with
"titi" set to "mystring". In a sqlite3 console, the SQL command
'select * from toto where titi=="mystring"' returns nothing. The same
command with the "like" operator finds the row. If the attribute is an
integer instead of a string, it works fine.

It is reproduceable with the default python on ubuntu 8.04 and the
latest storm from easy_install.

Did I miss something? should I file a bug?

$ python
>>> from storm.locals import *
>>> class toto(object):
...     titi = RawStr( primary=True )
...     __storm_table__ = 'toto'
...
>>> db=Store( create_database("sqlite:db.db") )

>>> t=db.add( toto() )
>>> t.titi='mystring'
>>> db.commit()
>>> db.find(toto, toto.titi=='mystring').one().titi
mystring

$ sqlite3 db.db 'select * from toto '
mystring

$ sqlite3 db.db 'select * from toto where titi=="mystring"'
$         # Returns nothing, this is unexpected !

$ sqlite3 db.db 'select * from toto where titi like "mystring"'
mystring

$ # A insertion with sqlite3 client works well
$ sqlite3 db.db 'insert into toto values ("mystring2")'
$ sqlite3 db.db 'select * from toto where titi=="mystring2"'
mystring2

I created another sqlite database 'db2.db' via the sqlite3 console
with the same schema and data. The hex diff between the databases
shows that two bytes differs, before the string. The strings appear
twice in the file.

When "corrected" with an hex editor, the broken select is fixed again.

$ diff <((xxd -c 18 db.db)) <((xxd -c 18 db2.db))
114c114
< 00007f2: 0000 0a01 021c 6d79 7374 7269 6e67 0a00 0000  ......mystring....
> 00007f2: 0000 0a01 021d 6d79 7374 7269 6e67 0a00 0000  ......mystring....
171c171
< 0000bf4: 031c 016d 7973 7472 696e 6701                 ...mystring.
> 0000bf4: 031d 016d 7973 7472 696e 6701                 ...mystring.

Regards,



More information about the storm mailing list