Hi. The model below works fine in 1.91.6, but gives an error in 1.92.1.
Traceback (most recent call last):
File "c:\web2py\gluon\restricted.py", line 188, in restricted
exec ccode in environment
File "c:/web2py/applications/tnt/models/db.py"
<http://localhost:8000/admin/default/edit/tnt/models/db.py>, line 34, in
<module>
migrate=migrate_database)
File "c:\web2py\gluon\dal.py", line 3493, in define_table
t._create_references()
File "c:\web2py\gluon\dal.py", line 3795, in _create_references
raise SyntaxError, "Table: table '%s'does not exist" % rtablename
SyntaxError: Table: table 'Employees'does not exist
I think it has something to do with dal converting table names to lower
case. If I change 'reference Employees' to 'reference employees' it gives me
a different error:
Traceback (most recent call last):
File "c:\web2py\gluon\restricted.py", line 188, in restricted
exec ccode in environment
File "c:/web2py/applications/tnt/models/db.py"
<http://localhost:8000/admin/default/edit/tnt/models/db.py>, line 34, in
<module>
migrate=migrate_database)
File "c:\web2py\gluon\dal.py", line 3493, in define_table
t._create_references()
File "c:\web2py\gluon\dal.py", line 3795, in _create_references
raise SyntaxError, "Table: table '%s'does not exist" % rtablename
SyntaxError: Table: table 'Departments'does not exist
Oddly enough, if I change db.Departments to db.departments in departmentId
and altDepartmentId fields it still gives me the same error message.
Model:
db.define_table('Departments',
Field('departmentID', 'id'),
Field('departmentName', length=50, notnull=True),
Field('departmentDescription', length=1000),
Field('altDepartmentID', length=10),
migrate=migrate_database)
db.define_table('Employees',
Field('employeeID', 'id'),
Field('networkDomain', length=20, notnull=True),
Field('networkUsername', length=20, notnull=True),
Field('firstName', length=20),
Field('lastName', length=20),
Field('managerID', 'reference Employees', ondelete="no action"),
Field('altManagerID', 'reference Employees', ondelete="no action"),
Field('departmentID', db.Departments, ondelete="no action", default=-1),
Field('altDepartmentID', db.Departments, ondelete="no action"),
Field('IndabaUsername', length=20),
Field('altEmployeeID', length=10),
Field('isManager', 'boolean', notnull=True, default=False),
Field('isSystemAdmin', 'boolean', notnull=True, default=False),
Field('createdDate', 'datetime', notnull=True, default=now),
Field('isTerminated', 'boolean', notnull=True, default=False),
Field('terminatedDate', 'datetime'),
migrate=migrate_database)