> > I've defined a table in my models file with the usual db.define_table > method/syntax, omitting my auto_increment id field (since web2py adds this > automatically). > However, when I perform a select on my table, I get very different results > depending on whether I include the id field in my list of fields to search > for: > > db().select(db.[tablename].[field1name], db.[tablename].[field2name], > [etc], orderby=None, limitby=None) > > - *without *[tablename].id in the list, I only get those fields that I > list. > - *with *[tablename].id in this list, I get all fields that I list, *as > well as* the Row functions - delete_record and update_record. > > This is a problem for me - I'm trying to JSON-serialize these rows after > reading them from the database. > > Why does including the id field in the arguments to select() cause these > functions to be included in the returned rows, and how can I tell select() > to omit these functions? >
As you might expect, those functions are there so you can apply them to update or delete specific records in the returned set (I guess they only appear when the id is included because they wouldn't work without knowing the record id). See http://web2py.com/books/default/chapter/29/6#update_record. To get rid of them, you might try applying the .as_list() method to the Rows object, which converts it to a list of dictionaries. See http://web2py.com/books/default/chapter/29/6#as_dict-and-as_list. Anthony

