Well, it appears to have been caused by me manually deleting the tables in the database, hoping that web2py will recreate them. Apparently, web2py does not know if the tables exist or not, and assumes that they do, since it has a log that it created the tables in the first place. That's why I get the error. It was assuming that my customers table was already created, and that assumption was incorrect.
On Thursday, March 22, 2012 3:12:50 PM UTC-7, Derek wrote: > > Yeah, I know. Baffles me. > Here's the traceback. I guess I'll go open an issue. > > 1. > 2. > 3. > 4. > 5. > 6. > 7. > 8. > 9. > 10. > 11. > 12. > 13. > 14. > 15. > 16. > 17. > > Traceback (most recent call last): > File "C:\Temp\web2py\gluon\restricted.py", line 204, in restricted > exec ccode in environment > File "C:/Temp/web2py/applications/newcustomers/models/db.py" > <http://10.11.58.41:8000/admin/default/edit/newcustomers/models/db.py>, line > 123, in <module> > Field('active','integer')) > File "C:\Temp\web2py\gluon\dal.py", line 5097, in define_table > polymodel=polymodel) > File "C:\Temp\web2py\gluon\dal.py", line 705, in create_table > self.create_sequence_and_triggers(query,table) > File "C:\Temp\web2py\gluon\dal.py", line 1348, in > create_sequence_and_triggers > self.execute(query) > File "C:\Temp\web2py\gluon\dal.py", line 1359, in execute > return self.log_execute(*a, **b) > File "C:\Temp\web2py\gluon\dal.py", line 1353, in log_execute > ret = self.cursor.execute(*a, **b) > ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL > Server]Foreign key 'contacts_customer_id__constraint' references invalid > table 'customers'. (1767) (SQLExecDirectW); [42000] [Microsoft][ODBC SQL > Server Driver][SQL Server]Could not create constraint. See previous errors. > (1750)") > > > On Thursday, March 22, 2012 3:03:26 PM UTC-7, Anthony wrote: >> >> I'll try adding the format to see if that helps. I was using 'database >>>>> administration' so maybe it's not using a SQLFORM there. >>>> >>>> >> Yes, appadmin uses SQLFORM and should show the dropdown as well (but only >> if the referenced table has a format specified or you add the validator >> manually). >> >> >>> I don't know what is going on... the dog and person tables work, but the >>> customers and contacts tables do not. >>> >> >> This is strange -- you can create the customers table by itself, add and >> query records, but if you then try to create the contacts table with a >> reference to customers, it gives you an error saying the customers table is >> invalid? I'm not sure what to make of that. >> >> Anthony >> >

