for me it is a case for coalesce in pure SQL. I know dal offers coalesce support but I did not try yet.
http://zerp.ly/rochacbruno Em 22/10/2011 09:47, "apple" <simo...@gmail.com> escreveu: > I am summing some data using the DAL: > cash_price = db.orderline.cash_price.sum() > lines = db(db.orderline.order_ == id).select(cash_price).first() > > However if there are no lines then lines[cash_price] is "None". So I > added: > lines[cash_price]=lines[cash_price] or 0 > But this does not work either. You have to do: > lines[cash_price]=lines._extra[cash_price] or 0 > > This is OK as it works. But wouldn't it be better if the sum were "0" > in the first place? Or if there is some logical reason for it to > "None" then one should to be able to say: > lines[cash_price]=lines[cash_price] or 0 > >