Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.2
-
Fix Version/s: 1.2.2
-
Component/s: Import/Export
-
Labels:None
-
Environment:PHP 5.3.1, WinXP-SP3, Doctrine 1.2.2, MySQL 5.1.41
Description
If you define a primary column, the attribute notnull is removed from the column definition because Doctrine assumes that primary columns are always not null.
Now suppose you have a schema like this, with a string primary column.
Client:
columns:
serial: { type: string(50), notnull: true, primary: true }
name: { type: string(36), notnull: true }
That's fine, but causes problems with MySQL where the column is created with a default value of "" (empty string) and not <none>.
CREATE TABLE client (serial VARCHAR(50), name VARCHAR(36) NOT NULL, PRIMARY KEY(serial)) ENGINE = INNODB;
Note that the 2nd column is well defined and has <none> as default value (as seen from phpMyAdmin).
I attached a quick-workaround to disable the code which removes the notnull attribute from column definition.
After that the SQL code is like this:
CREATE TABLE client (serial VARCHAR(50) NOT NULL, name VARCHAR(36) NOT NULL, PRIMARY KEY(serial)) ENGINE = INNODB;
Activity
Claudio Nicora
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
If you define a *string* primary column, the attribute *notnull* is removed because Doctrine assumes that primary columns are always not null. {code}Client: columns: serial: { type: string(50), notnull: true, primary: true } name: { type: string(36), notnull: true } {code} That's fine, but on mysql the column is created with a default value of "" (empty string) and not <none>. {code} CREATE TABLE client (serial VARCHAR(50), name VARCHAR(36) NOT NULL, PRIMARY KEY(serial)) ENGINE = INNODB; {code} Note tha the 2nd column is ok and has a default value (seen from phpMyAdmin) of <none>. I attached a quick-workaround to disable the code which removes the *notnull* attribute from column definition. The SQL code is now like this: {code} CREATE TABLE client (serial VARCHAR(50) NOT NULL, name VARCHAR(36) NOT NULL, PRIMARY KEY(serial)) ENGINE = INNODB; {code} |
If you define a primary column, the attribute *notnull* is removed from the column definition because Doctrine assumes that primary columns are always not null. Now suppose you have a schema like this, with a *string* primary column. {code}Client: columns: serial: { type: string(50), notnull: true, primary: true } name: { type: string(36), notnull: true } {code} That's fine, but causes problems with MySQL where the column is created with a default value of "" (empty string) and not <none>. {code} CREATE TABLE client (serial VARCHAR(50), name VARCHAR(36) NOT NULL, PRIMARY KEY(serial)) ENGINE = INNODB; {code} Note that the 2nd column is well defined and has <none> as default value (as seen from phpMyAdmin). I attached a quick-workaround to disable the code which removes the *notnull* attribute from column definition. After that the SQL code is like this: {code} CREATE TABLE client (serial VARCHAR(50) NOT NULL, name VARCHAR(36) NOT NULL, PRIMARY KEY(serial)) ENGINE = INNODB; {code} |
Claudio Nicora
made changes -
| Attachment | patch.diff [ 10617 ] |
Claudio Nicora
made changes -
| Attachment | patch.txt [ 10616 ] |
Claudio Nicora
made changes -
| Attachment | patch.diff [ 10618 ] |
Claudio Nicora
made changes -
| Attachment | patch.diff [ 10617 ] |
Claudio Nicora
made changes -
| Attachment | export_mysql_patch.diff [ 10642 ] |
Claudio Nicora
made changes -
| Attachment | patch.diff [ 10618 ] |