robotoworks / mechanoid

Eclipse plugin providing a set of DSL's for the rapid development of Android apps
58 stars 26 forks source link

select from a view with group by return no records #212

Closed hannesa2 closed 10 years ago

hannesa2 commented 10 years ago

When I have a view with 'group by' an I want to filter in a query. as result no records are found

    create table child (
        _id integer primary key autoincrement,
        main_Id integer
    );
    create view childsum as
        select 
            _id as _id,
            main_Id as main_Id,
            count ( * ) as countcol
        from child
        group by main_Id;

query.expr(Childsum.COUNTCOL, Op.GT, 1);

this is not working, I created a test app https://github.com/hannesa2/mechanoid.viewwithgroupby please go to third tab 'childsum' and see what's happen during select checkbox

hannesa2 commented 10 years ago

I figured out

query.expr(Childsum.COUNTCOL, Op.GT, 1);

is not working, but this works perfect

query.append(Childsum.COUNTCOL + " > 1");

you can see it in test-app FragmentTab.java line 92

fluxtah commented 10 years ago

Hi this can occur if the column in the view is not a defined data type, try casting the column in your view to an integer using the SQL cast function.

On 30 Apr 2014 09:11, hannesa2 notifications@github.com wrote: I figured out

    query.expr(Childsum.COUNTCOL, Op.GT, 1);

is not working, but this works perfect

    query.append(Childsum.COUNTCOL + " > 1");

you can see it in test-app FragmentTab.java line 92


Reply to this email directly or view it on GitHub: https://github.com/robotoworks/mechanoid/issues/212#issuecomment-41770907

hannesa2 commented 10 years ago

Awesome, this was the problem !