Anthony,

Thanks for answering so quickly.
I did mean board and not board_id

My question is very basic.
I know that the article table has an Id column that is really the board 
reference, but when I look at the result of the query and unification of:
board_ids = set(map(lambda a: a.board, articles))

I get a set of references,
how do I use that set in another query to get all the boards?
also, just to be sure, running this lambda expression does not hit the db 
to fetch the boards, right?

I can't use join b/c I'm running on GAE.



On Wednesday, March 21, 2012 5:22:50 PM UTC-4, Anthony wrote:
>
> I have two db tables:
>>
>> board (name, created_on)
>> article(board, name, title)
>>
>> currently, in my html I do a naive loop {{for article in articles}} {{=
>> article.board.name}} {{pass}}
>>
>> I would like to change it and do something like:
>> articles = db.select.all.......
>> board_ids = set(map(lambda a: a.board_id, articles))
>>
>
> Instead of a.board_id, do you mean a.board (I don't see a "board_id" field 
> listed in your article table definition)? Also, is db.article.board a 
> reference field to the db.board table? In that case, that means it is 
> already storing the id of the referenced record in the db.board table 
> (that's what reference fields store), so you don't need to retrieve it 
> separately.
>
> Anyway, if you need the db.board.name value for all the records you are 
> selecting from the db.article table, you should probably just do a join so 
> you can get everything in a single query -- see 
> http://web2py.com/books/default/chapter/29/6#Inner-joins.
>  
> Anthony
>
>

Reply via email to