Hello,
I posted on this issue some time ago and I'm pretty sure it was working 
again after a fix from DenesL.
However I can't get Primary Key tables in MSSQL to work.  They get created 
OK, but I get errors with a Form in a view.
I originally made the Key a string, but then switched to integer just to 
see if it made a difference.  :

*Model:*
dbSQL = DAL('mssql://....)
# 1 Column PK
dbSQL.define_table('web2py_int_PK',
                Field('Field1', 'integer'),
                Field('Field2', 'string', length=20),
                format='%(Field1)s',
                primarykey = ['Field1'],
                migrate=True)

*Controller:*
def web2py_int_PK_form():
    form = SQLFORM(dbSQL.web2py_int_PK)
    if form.process().accepted:
        response.flash = 'form accepted'   
    elif form.errors:       
        response.flash = 'form has errors'   
    else:       
        response.flash = 'please fill out the form'
    return dict(form=form)     

*View:*
{{extend 'layout.html'}}
<h1>Primary Key Form Test</h1>
{{=form}}

I get this in the ticket:
File "D:\Mercurial\web2py\gluon\dal.py", line 6912, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: '_id'

It looks like it is trying to retrieve the value for "_id" , but looking at 
the code __init__ for a table, _id never gets set for a table with a 
Primary Key.  (look at lines 6752, 6762, 6772).

Just wondering if something like line 772 in sqlhtml.py (In the SQLFORM 
__init__ method).          "self.id_field_name = table._id.name"  could 
cause the above lookup of the _id key ?  Do Forms work with keyed tables ?

Thanks
Andrew W


Reply via email to