There is a logic and these two {{=board._extra['COUNT(mb_posts2.id)']}} {{=board._extra[mb_posts2.id.count()]}} should be equivalent, in fact {{=mb_posts2.id.count()}} should be 'COUNT(mb_posts2.id)'.
The rationale is that rows=db(...).select (table.field,table.field.aggregate()) table field goes in rows[i].table.field while aggregates are not fields so they go in rows[i]._extra [table.field.aggregate()] Massimo On Apr 3, 11:37 am, TheDude <officed...@gmail.com> wrote: > THat didn't work but.. > > {{=board._extra.keys()}} brings up ['COUNT(mb_posts.id)', 'COUNT > (mb_posts2.id)'] > > So I did {{=board._extra['COUNT(mb_posts2.id)']}} and it works! > > Now, the only problem I have with this, is that it doesn't make to > much logical sense to do things this way (it doesn't seem like a > framework way more like a quick hack). Will there be any modifications > within this area in 1.6? > > On Apr 3, 11:55 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > {{=board._extra[mb_posts2.id.count()]}} ? > > > On Apr 3, 10:01 am, TheDude <officed...@gmail.com> wrote: > > > > RIght tried those already... > > > .keys() brings up ['update_record', 'mb_posts', 'description', 'id', > > > 'name'] > > > board._extra = no xml error > > > > I tried listing keys() and dir() mb_posts (see if it was somehow > > > placed in there but it isn't). > > > > However, {{=query}} brings this... > > > mb_boards.id mb_boards.name mb_boards.description COUNT(mb_posts.id) > > > COUNT(mb_posts2.id) > > > 1 Announcements All important... 1 1 > > > 2 General Discu... General talk ... 1 1 > > > 3 Suggestions/B... Report any bu... 0 0 > > > 4 Off-Topic Not everythin... 0 0 > > > > On Apr 3, 10:34 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > try: > > > > {{=board.mb_boards.keys()}} > > > > {{=board._extra}} > > > > > On Apr 2, 5:20 pm, TheDude <officed...@gmail.com> wrote: > > > > > > SQL Works! However... > > > > > > {{=board.mb_boards.keys()}} > > > > > brings up: > > > > > ['update_record', 'mb_posts', 'description', 'id', 'name'] > > > > > > As you can see, no mb_posts2 (mb_posts does not contain mb_posts2 > > > > > either). So, I said to myself may be it's because of the .ALL within > > > > > the select. Still no go. > > > > > > On Apr 2, 2:56 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > ry > > > > > > > def index(): > > > > > > rows = (db.mb_posts.board_id==db.mb_boards.id)& > > > > > > (db.mb_posts.reply_to==0) > > > > > > mb_posts2 = db.mb_posts.with_alias("mb_posts2") > > > > > > rows2 = (mb_posts2.board_id==db.mb_boards.id) > > > > > > query = db().select(db.mb_boards.ALL, db.mb_posts.id.count(), > > > > > > mb_posts2.id.count(), left=(db.mb_posts.on(rows),mb_posts2.on > > > > > > (rows2)), groupby=db.mb_boards.id) > > > > > > return dict(query=query) > > > > > > > On Apr 2, 8:08 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > > should be > > > > > > > > def index(): > > > > > > > rows = (db.mb_posts.board_id==db.mb_boards.id)& > > > > > > > (db.mb_posts.reply_to==0) > > > > > > > mb_posts2 = db.mb_posts.with_alias("mb_posts2") > > > > > > > rows2 = (db.mb_posts2.board_id==db.mb_boards.id) > > > > > > > query = db().select(db.mb_boards.ALL, db.mb_posts.id.count(), > > > > > > > db.mb_posts2.id.count(), > > > > > > > left=(db.mb_posts.on(rows),db.mb_posts2.on > > > > > > > (rows2)), groupby=db.mb_boards.id) > > > > > > > return dict(query=query) > > > > > > > > On Apr 1, 11:13 pm, TheDude <officed...@gmail.com> wrote: > > > > > > > > > def index(): > > > > > > > > rows = (db.mb_posts.board_id==db.mb_boards.id)& > > > > > > > > (db.mb_posts.reply_to==0) > > > > > > > > rows2 = (db.mb_posts.board_id==db.mb_boards.id) > > > > > > > > mb_posts2 = db.mb_posts.with_alias("mb_posts2") > > > > > > > > query = db().select(db.mb_boards.ALL, > > > > > > > > db.mb_posts.id.count(), > > > > > > > > db.mb_posts2.id.count(), > > > > > > > > left=(db.mb_posts.on(rows),db.mb_posts2.on > > > > > > > > (rows2)), groupby=db.mb_boards.id) > > > > > > > > return dict(query=query) > > > > > > > > > gives me > > > > > > > > OperationalError: (1066, "Not unique table/alias: 'mb_posts'") > > > > > > > > > However, should mb_posts2 show itself as LEFT JOIN mb_posts AS > > > > > > > > mb_posts2 ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---