On Tuesday, June 2, 2015 at 2:31:41 PM UTC-4, Alex Glaros wrote: > > dumb question > > this works > > response.subtitle = T(db.Organization(db.auth_group(request.get_vars. > specificRoleID).organizationID).organizationFullName) > > 1. is it okay programming practice? >
Sure, though it involves two separate selects, whereas you could get the same result with a single select involving a join. Also, web2py has a built-in method for doing the same thing more concisely: db.auth_group(request.get_vars.specificRoleID).organizationID. organizationFullName web2py calls the above a recursive select <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Recursive-selects>, and it does exactly the same thing as your code (i.e., it does two separate selects). 2. what is it called, "using pointers", or "nested reference", or what? > Not sure it has a specific name, other than the "recursive select" term applied to the special web2py shortcut syntax. > 3. is it faster or much faster or better than doing join on tables to get > same values? > I believe a single join would typically be faster: row = db((db.auth_group.id == request.get_vars.specificRoleID) & (db.auth_group.organizationID == db.Organization.id)).select(). first() row.Organization.organizationFullName However, depending on the context, the difference may be negligible, so you may still prefer the recursive select approach. Also, keep in mind that the shortcut syntax selects all the fields in each record, whereas if you use the more explicit .select() method, you can fetch only the field(s) you need. In this case, because you need only a single field, you could speed things up using the more explicit method (whether or not you use a join or two separate selects). Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.