From: <py...@to...> - 2006-06-15 10:16:37
|
Oleg Broytmann a =E9crit : > On Thu, Jun 15, 2006 at 10:30:41AM +0200, Fran?ois wrote: > =20 >>> There is sqlbuilder.Alias, >>> =20 >> But Alias is for Tables, no? >> =20 > > Oops, sorry, it is. There are no field aliases and adding ones would= be > a bigger job - one needs to patch all places where SQLObject generates = SQL > query strings in dbconnection.py, main.py and sqlbuilder.py. > > Oleg. > =20 OK, so for SELECT COUNT(table.field1) as MyAlias FROM table GROUP BY table.field2 ORDER BY MyAlias DESC I make : count =3D func.COUNT(Table.q.field1) sql =3D conn.sqlrepr(sqlbuilder.Select([count] =20 ,groupBy=3DTable.q.field2 ) ) alias =3D 'MyAlias' count_original =3D "%s" % count count_replace =3D "%s AS %s" % (count, alias) sql.replace(count_original, count_replace) return conn.queryAll(sql + " ORDER BY %s DESC" % alias) Not really nice, but working :-) Fran=E7ois |