so here is your test case: from sqlalchemy.sql import column from sqlalchemy import Integer
x = (column("foo", Integer) * column("bar", Integer)) == 27 assert isinstance(x.right.type, Integer) you show me what is particular about your setup that causes "x.right.type" to be String, or something other than Integer. Choices include: - SQLAlchemy version (the above is 0.6.3) - types of the "qty" and "price" columns are not Integer - etc. you should be able to reproduce the above code using your Sometable.qty and Sometable.price column objects. On Jul 22, 2010, at 5:05 PM, Timuçin Kızılay wrote: > I have a strange problem in sa. > I've asked turbogears mailinglist and someone there suggested to post it here > too. > > I've forwarded the post from there but here is an example of the problem. > > example code: > prc_filter=24 > q_sometable=DBSession.query(model.Sometable) > q_sometable=q_sometable.filter((model.Sometable.qty*model.Sometable.price)==prc_filter) > ---------- > > I'm trying to filter a query by two colums multiplied. I think this is a > common filtering operation. > I'm using turbogears 2.1b2 and sqlite. > > And some other person from TG mailinglist told me that this problem is sqlite > only, he had the same problem too and it was solved when he switched to mysql. > > And this one works. When I send the filter as string like this: > ------------ > f = u'sometable.qty * sometable.price = 24' > q_sometable = q_sometable.filter(f) > ---------- > > > > > > -------- Orijinal Mesaj -------- > Konu: Re: [TurboGears] strange sql query problem. > Tarih: Thu, 22 Jul 2010 12:34:00 +0200 > Kimden: Diez B. Roggisch <de...@web.de> > Cevapla: turboge...@googlegroups.com > Kime: turboge...@googlegroups.com > Tercihler: <4c4813a1.7040...@savaskarsitlari.org> > <201007221207.48136.de...@web.de> <4c481c75.4090...@savaskarsitlari.org> > > On Thursday, July 22, 2010 12:24:53 Timuçin Kızılay wrote: >> Diez B. Roggisch yazmış: >> > On Thursday, July 22, 2010 11:47:13 Timuçin Kızılay wrote: >> >> I'm trying to make a query like this: >> >> >> prc_filter = 24 >> >> >> q_sometable = DBSession.query(model.Sometable) >> >> q_sometable = q_sometable.filter((model.Sometable.qty * >> >> model.Sometable.price)==prc_filter) >> >> >> This do not give any error and when I look at the paster log I see that >> >> it generated a query with where part like this: >> >> >> ------------ >> >> WHERE sometable.qty * sometable.price = ? >> >> >> 12:41:24,272 INFO [sqlalchemy.engine.base.Engine.0x...ba0c] ['24'] >> > > This looks as if the above is *not* what you really do. Because '24' is a >> > *string*, not an integer... >> > > Diez >> No, it's an integer but the log shows it as string. >> I think the problem is filtering on two columns multiplied. >> When I filter only one column, it works. >> q_sometable = q_sometable.filter(model.Sometable.price==prc_filter) >> this filter works and generated sql shown on the log is still ['24'] but >> it works. > > Ah. Strange enough. > >> I think it's a SA bug, it try to put those values into query as parameters. > > If so, I suggest you take it to the SA-mailinglist. Michael Bayer is > incredible responsive. Of course you should try with the latest + greatest SA > first. > > Diez > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" group. > To post to this group, send email to turboge...@googlegroups.com. > To unsubscribe from this group, send email to > turbogears+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/turbogears?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.