dundeemt
unread,Feb 27, 2008, 9:28:43 AM2/27/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to SQLElixir
I am not sure if this should be reported here or on the SA group - so
I figured I would start here.
Synopsis: Using deferred_groups in a class that also utilizes an
attribute with a 'synonym' property causes an error when an attribute
from the deferred_group is accessed.
Example Code:
from elixir import *
from sqlalchemy.orm import undefer_group
metadata.bind = "sqlite:///"
metadata.bind.echo = True
class TestGood(Entity):
custname = Field(Unicode(16), index=True)
address1 = Field(Unicode(16), deferred=True)
_note = Field(Binary, colname='note', synonym='note',
deferred=True)
def _set_note(self, note):
self._note = note
def _get_note(self):
return self._note
note = property(_get_note, _set_note)
def __repr__(self):
return '<TestGood "%s:%s">' % (self.custnmbr,
self.custname.encode('ascii','replace'))
class TestBad1(Entity):
custname = Field(Unicode(16), index=True)
address1 = Field(Unicode(16), deferred='deferreds')
_note = Field(Binary, colname='note', synonym='note',
deferred=True)
def _set_note(self, note):
self._note = note
def _get_note(self):
return self._note
note = property(_get_note, _set_note)
def __repr__(self):
return '<TestBad1 "%s:%s">' % (self.custnmbr,
self.custname.encode('ascii','replace'))
class TestBad2(Entity):
custname = Field(Unicode(16), index=True)
address1 = Field(Unicode(16), deferred='deferreds')
_note = Field(Binary, colname='note', synonym='note',
deferred='deferreds')
def _set_note(self, note):
self._note = note
def _get_note(self):
return self._note
note = property(_get_note, _set_note)
def __repr__(self):
return '<TestBad2 "%s:%s">' % (self.custnmbr,
self.custname.encode('ascii','replace'))
setup_all(True)
TestGood(custname=u'name',address1=u'address',note=u'note')
TestBad1(custname=u'name',address1=u'address',note=u'note')
TestBad2(custname=u'name',address1=u'address',note=u'note')
session.flush()
#works
print "TEST CONTROL - individual deferreds"
for r in TestGood.query.all():
print r.custname,r.note
#fails with AttributeError: SynonymnProperty has not attribute
'strategy'
print "TEST 1 - group deferred + individual on the note attribute"
for r in TestBad1.query.all():
print r.custname,r.address1,r.note
#fails with AttributeError: SynonymnProperty has not attribute
'strategy'
print "TEST 2 group deferred only"
for r in TestBad2.query.all():
print r.custname,r.address1,r.note
#fails with AttributeError: SynonymnProperty has not attribute
'strategy'
print "TEST 3 - group deferred only with query.options defined"
for r in TestBad2.query.options(undefer_group('deferreds')).all():
print r.custname,r.address1,r.note
--end code--
-jeff