Python 2.5.4
MySQL python 1.2.3c1
sqlalchemy 0.5.2

Here is the actual code.  It references my object model etc so it
won't run for you, but just in case I made a mistake converting it to
a simplified version of the problem here it is:

dollars = func.if_(EmpTime.actTotal != None, EmpTime.actTotal,
                EmpTime.estTotal, type_=types.Numeric)
q = orm.query(
                Account.code,
                func.lower(TimeType.shortName),
                func.sum(EmpTime.hours),
                func.sum(dollars, type_=types.Numeric)
                )
q = q.join(EmpTime.acc).join(EmpTime.timeType)
q = q.group_by(Account.code).group_by(TimeType.shortName)
q = q.filter(EmpTime.day >= start)
q = q.filter(EmpTime.day <= end)
q = q.filter(EmpTime.jobId == jobId)
labor = q.all()


On Aug 3, 1:26 pm, Michael Bayer <[email protected]> wrote:
> On Aug 3, 2010, at 2:56 PM, Bryan wrote:
>
> > This returns a Decimal type for c2, which is what I want:
> > c1 = literal(5, type_=Numeric)
> > c2 = func.sum(c1, type_=Numeric)
>
> > This returns a Float type for c2, but I'm telling c1 that it is a
> > Numeric.  How can I get a decimal returned when using an if function?
> > c1 = func.if_(Table.foo != None, Table.foo, Table.bar, type_=Numeric)
> > c2 = func.sum(c1, type_=Numeric)
>
> I see nothing wrong with that code.    Can I get some SQLA version / database 
> backend / DBAPI details ?
>
>
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "sqlalchemy" 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 
> > athttp://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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to