OK. Now in trunk:
>>> db=DAL()
>>> db.define_table('a',Field('b'),Field('c'))
>>> db(db.a.b>0)._count()
"SELECT count(*) FROM a WHERE (a.b > '0')"
>>> db(db.a.b>0)._count(distinct=db.a.b)
"SELECT count(DISTINCT a.b) FROM a WHERE (a.b > '0')"
>>> db(db.a.b>0)._count(distinct=db.a.b|db.a.c)
"SELECT
Postgres too!
On Fri, Jan 28, 2011 at 1:41 PM, villas wrote:
>> It seems to work in SQLite and MS-SQL though.
>
> Firebird seems OK too.
>
>
OK. 3 is enough. Please add a google code issue and I will add it
asap. Meanwhile if you want to try build a patch, it would be a new
exercise in understainding the new dal. search for "def count" in the
file.
On Jan 28, 10:41 am, villas wrote:
> > It seems to work in SQLite and MS-SQL though.
>
> It seems to work in SQLite and MS-SQL though.
Firebird seems OK too.
Can we not add per-dialect identifiers to DAL... I can see adding this just
for postgres & ms sql.
--
Thadeus
On Fri, Jan 28, 2011 at 8:43 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:
> This is not supported because I am not sure all supported RDBS support
> count(distinct ...).
Thank you very much!
On Jan 28, 2:43 pm, Massimo Di Pierro
wrote:
> This is not supported because I am not sure all supported RDBS support
> count(distinct ...).
>
> As a way around it you can do
>
> len(db().select(db.item.of_variant,distinct=True))
>
> Massimo
>
> On Jan 28, 6:32 am, vortex wr
This is not supported because I am not sure all supported RDBS support
count(distinct ...).
As a way around it you can do
len(db().select(db.item.of_variant,distinct=True))
Massimo
On Jan 28, 6:32 am, vortex wrote:
> How to do a count distinct with DAL?
>
> like:
>
> db().count(db.item.of_vari
The SQL command would be
SELECT COUNT(DISTINCT item.of_variant) FROM item;
but I believe that is not something you can build in the DAL
currently.
In addition that SQL command might not be supported by all the backend
DBs.
It seems to work in SQLite and MS-SQL though.
So you have two options:
1)
8 matches
Mail list logo