working on tracing error gets me to line 3196 of sql.py: sql_o += ' ORDER BY %s' % ', '.join(['%s.%s'%(t,x) for t in w2p_tablenames for x in ((hasattr(self._db[t],'_primarykey') and self._db[t]._primarykey) or ['id'])])
Problem is that with this table definition: db.define_table('mytable', Field('my_id', 'id') ) This line: hasattr(db.mytable, '_primarykey') # returns False It seems like the above line should return True and db.mytable._primarykey should equal 'my_id'. Which makes me think the problem actually goes back to define_table. -Mike On Sep 21, 4:44 pm, mwolfe02 <michael.joseph.wo...@gmail.com> wrote: > I'm using a legacy tables and trying to use the shortcut method of > returning a row/record by passing the value of the ID field directly > to the table. It appears that 'id' is still hardcoded into the logic > at some level, though. This works: > > db.mytable(db.mytable.my_id==1) > > But this does not: > > db.mytable(1) > > # returns ProgrammingError: ('42S22', "[42S22] [Microsoft][ODBC SQL > Server Driver][SQL Server]Invalid column name 'id'. (207) > (SQLExecDirectW)") > # for a table defined as follows: > > db.define_table('mytable', > Field('my_id', 'id') > ) > > db.mytable(1) > > # returns KeyError: 'id' > # for a table defined as follows: > > db.define_table('mytable', > Field('my_id', 'id'), > primarykey=['my_id'] > ) > > I can understand the second case failing, as primarykey seems like it > would be usually used to define a multi-field key. In such a case, a > single value would not be enough to identify a record, anyway. I > tried this simply as a workaround for the original problem, but with > no success.