The following code raises an exception in Storm 0.17. It works as expected in 0.16
>>> from storm.locals import *
>>> database = create_database("sqlite:")
>>> store = Store(database)
>>>
>>> class Foo(object):
... __storm_table__ = 'foo'
... id = Int(primary=1)
... bar_id = Int()
...
>>> class Bar(object):
... __storm_table__ = 'bar'
... id = Int(primary=1)
... foos = ReferenceSet(id, Foo.id, order_by = Desc(Foo.id))
..
>>> bar = store.add(Bar())
>>> bar.foos
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "storm-0.17-py2.6-freebsd-8.1-BETA1-i386.egg/storm/references.py", line 243, in __get__
if self._relation2 is None:
File "storm-0.17-py2.6-freebsd-8.1-BETA1-i386.egg/storm/references.py", line 51, in __get__
getattr(obj, self._attr_builder)()
File "storm-0.17-py2.6-freebsd-8.1-BETA1-i386.egg/storm/references.py", line 257, in _build_relations
self._order_by = resolver.resolve(self._default_order_by)
File "storm-0.17-py2.6-freebsd-8.1-BETA1-i386.egg/storm/references.py", line 907, in resolve
return (self.resolve_one(properties),)
File "storm-0.17-py2.6-freebsd-8.1-BETA1-i386.egg/storm/references.py", line 916, in resolve_one
return _find_descriptor_obj(self._used_cls, property)
File "storm-0.17-py2.6-freebsd-8.1-BETA1-i386.egg/storm/references.py", line 945, in _find_descriptor_obj
raise RuntimeError("Reference used in an unknown class")
RuntimeError: Reference used in an unknown class
Also broken with string reference for column name:
from storm.locals import *
class Foo(Storm):
__storm_table__ = 'foo'
id = Int(primary=True)
class Bar(Storm):
__storm_table__ = 'bar'
id = Int(primary=True)
foo_id = Int()
foos = ReferenceSet( foo_id, 'Foo.id', order_by= Desc('Foo. id'))
db = create_ database( 'sqlite: ')
store = Store(db)
store.execute( 'create table foo (id integer primary key)') 'create table bar (id integer primary key, foo_id integer)')
store.execute(
store.flush()
f = store.add(Foo())
b1 = store.add(Bar())
b1.foos.add(f)