Every question answered. Thanks a lot, Anthony! On Thursday, August 23, 2012 3:27:07 PM UTC-4, Anthony wrote: > > 1. When you do a select that includes a reference field, how does it >> fetch, say, the name column, when only the id column is in the table you >> are doing a select on? >> > > Unless you do a join, it does not fetch the "name" column (presumably you > mean the "name" column of the referenced table) at the time of the initial > select. However, if you access the "name" attribute of one of the returned > Row objects, it will do a query to fetch the "name" field for that > particular record. If you check the type of the reference field of the Row > object, you'll see that it is a DAL Reference object -- this holds the > value of the referenced record id but also knows how to fetch the > associated record from the referenced table. This is called a recursive > select <http://web2py.com/books/default/chapter/29/6#Recursive-selects>. > Note, because recursive selects involve a separate query for each record, > if you need the referenced fields for many records, it is more efficient to > do a single query with a join instead. > > >> 3. My list:reference fields hold a series of integer values but they do >> so in a column of type 'text' . They are strings of integers separated with >> '|'. If I were going to use SQL, rather than DAL methods to update a >> list:reference field of this kind, would inserting a string like this - >> '|100|300|450|' - work the same as a field updated by the DAL with a list? >> Or is the DAL doing something else behind the scenes when you update the >> field that would be excluded from a simple SQL update. >> > > I don't think the DAL is doing anything special other than creating a > string as you describe above, so you should be able to make your own > inserts using SQL if you like. > > Anthony >
--

