Am 19.07.2010 um 00:40 schrieb Timuçin Kızılay:
ok, here is what I do for record updates...
-----------------------
rec = model.DBSession.query(model.Sometable).filter_by(id=id).one()
rec.a = 'some new text'
model.DBSession.flush()
---------------------
I can add a property to the model object but I do now know how to
filter by a property.
here is model object with property added:
----------------------------
class Sometable(DeclarativeBase):
__tablename__ = 'sometable'
id = Column(Integer, autoincrement=True, primary_key=True)
a = Column(Unicode(50))
b = Column(Unicode(50))
@property
def c(self):
return self.a + self.b
----------------------
this works but I need to make queries like this :
q =
model
.DBSession
.query(model.Sometable).filter(model.Sometable.c.like('something'))
That's why I need to have another field.
You should be able to concatenate the fields + then operate on that
with like.
Like (untested)
= model.DBSession.query(model.Sometable).filter((model.Sometable.a
| model.Sometable.b).like('something'))
As the SA-ML about this, with the operator your DB uses for
concatenation. OR maybe there is a function.
Diez
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.