robotoworks / mechanoid

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

view with group by and union don't generate XXXRecord #258

Closed hannesa2 closed 1 year ago

hannesa2 commented 9 years ago

here the record class will not be generated.I found a sql workaround but maybe you want to make mechanoid more perfect. Union makes the problem

    create view vehiclegroup as
      select _id as _id, name as name, 
        count(*) as cnt, 
        sum(canBeRented) as canBeRented
        from vehicle where name <> '-'
        group by name;
     union
      select _id, name, 1 as cnt, canBeRented
       from vehicle where name = '-';

here cast makes the problem

      select _id, name, count(*), 
        cast (sum(canBeRented) as integer) as canBeRented
        from vehicle where name <> '-'
        group by name
     // union
     // select _id, name, 1, canBeRented
     //  from vehicle where name = '-'

btw, I solved it like this (group only with valid name)

    create view vehiclegroup as
       select _id as _id, case when name <> '-' then name else name||_id end as name, 
        count(*) as cnt, 
        sum(canBeRented) as canBeRented
        from vehicle 
        group by case when name <> '-' then name else name ||_id end;