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.

Reply via email to