Nope, DAL is not an ORM. 
However, given that when you write DAL queries you're the man in control, 
it's quite difficult to gain something by "reducing" the number of 
generated queries while coding on web2py.

Unit of Work in an ORM (fake example, just to grasp the idea):

product = db.products(10) #product with id 10
product.description = 'product description' #update product description
product.stock = 11 #we have 11 in stock
product.code = 'abcfed' #update the product code

Then, you ask the ORM to save the changes you did to your product back to 
the products table.
Generated query (unit of work of 3 updates aggregated with a single query): 
update products set description = 'product description', stock = 11, code = 
'abcfed' where id = 10

Now, back to web2py code
product = db.products(10) #product with id 10
product.update_record(description = 'product description',stock = 11,code = 
'abcfed')
Generated query: 
update products set description = 'product description', stock = 11, code = 
'abcfed' where id = 10
it's the same one. And you get to choose when fire an update, not the 
underlying code.

Of course if you do
product.update_record(description = 'product description')
product.update_record(stock = 11)
product.update_record(code = 'abcfed')
queries will be 3, but your code is the one to blame.

How do you imagine a "unit of work" pattern/algo in a DAL ?

-- 



Reply via email to