Naming a model field to "num_connections" causes syncdb to seemingly ignore it (mysql)
|Reported by:||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.2|
|Severity:||Normal||Keywords:||model, field, syncdb, mysql|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Not sure this is a bug or a case of an undocumented restriction.
Naming a model field (in this case a PositiveIntegerField) "num_connections" and doing a syncdb causes the field to be ignored completely. There is no error and the table is create in the database, just without the num_connections field. To check that the model itself is not broken in other ways (and obfuscating the real cause of the problem) I have tried renaming the "num_connections" field to other things and it then works. So it appears that it is the name "num_connections" is somehow restricted.
The database in this case is mysql. Fields with this name can be created by a normal ALTER TABLE so it does not appear to be a problem in mysql but a problem in django.
Consequences: Aside from the obvious, that the column is not created in the database, django does not seem to fully understand that it does not exist. Trying to save data into the field does not seem to crash, it is just ignore. I found the error when doing an order_by on the field, which caused an error as the field did not exist.
This might be a case of num_connection simply being reserved in either python or django but if this is the case I can't find any documentation on the subject.