Non-standard SQL generated in column definition for nullable columns in create table DDL
|Reported by:||Ambrish||Owned by:||mtredinnick|
|Component:||Database layer (models, ORM)||Version:||1.0|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
While doing backend testing for new DB2 adapter (I am developing it), I found that in CREATE TABLE DDL generation, it contains some non-standard SQL syntax.
Here is one example of model.
class User(models.Model): first_name = models.CharField(max_length=20, null=False) last_name = models.CharField(max_length=20, null=True) class Meta: db_table = "temp_user"
For the column last_name, the SQL that gets generated is LAST_NAME VARCHAR(20) NULL. The trailing NULL is not a standard SQL. This can be validated by the SQL validator tool - http://developer.mimer.com/validator/parser200x/index.tml Needless to say, this will fail in DB2 and so too in Oracle.
I find only one method in the docs which deals with the table DDL generation BaseDatabaseCreation.sql_create_model.
Change History (9)
Changed 5 years ago by ikelly
comment:4 Changed 5 years ago by ikelly
- Component changed from Uncategorized to Database layer (models, ORM)
- Has patch set
comment:6 Changed 5 years ago by mtredinnick
- Owner changed from nobody to mtredinnick
- Status changed from new to assigned
comment:7 Changed 5 years ago by mtredinnick
- Resolution set to fixed
- Status changed from assigned to closed