This is because of a bug fixed in 1.51. Replace
print rows[0]._extra[shortname]
with
print rows[0]._extra[str(shortname)]
and it should work.
Massimo
On Nov 28, 8:15 am, Tari <[EMAIL PROTECTED]> wrote:
> I'm using 1.50, and tried the EXACT same code you provided as an
> example...
>
> On Nov 28, 2:31 am, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > which version do you have? Could you show me the exact code you are
> > using?
>
> > On Nov 27, 6:17 pm, Tari <[EMAIL PROTECTED]> wrote:
>
> > > Tnaks for the quick reply.
>
> > > I have tried your code, but it gives me a:
> > > KeyError: <gluon.sql.SQLXorable object at 0x2797b90>
>
> > > Any ideas?
>
> > > On Nov 27, 4:09 am, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > > > You can since 1.49
>
> > > > >>> db=SQLDB()
> > > > >>> db.define_table('t',SQLField('a','integer'),SQLField('b','integer'))
> > > > >>> db.t.insert(a=2,b=3)
> > > > 1
> > > > >>> db.t.insert(a=3,b=7)
> > > > 2
> > > > >>> shortname=db.t.a.sum()+db.t.b.sum()
> > > > >>> rows=db(db.t.id>0).select(shortname)
> > > > >>> print rows[0]._extra[shortname]
>
> > > > 15
>
> > > > On Nov 26, 7:55 pm, Tari <[EMAIL PROTECTED]> wrote:
>
> > > > > I thought I'd go ahead and ask, and stopgooglingin vain...
>
> > > > > Is there a way to rename a field in a select, e.g. as in
>
> > > > > "SELECT SUM(column1) + SUM(column2) AS shortname ..."
>
> > > > > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---