Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Labels:None
-
Environment:Doctrine 1.2.2
MySQL 5.0.45
PHP 5.2.5
Description
When writing a migration class for a table I wanted to add a new column of the SET type. I've set the notnull option and a default value, but Doctrine fails to generate the correct SQL.
Migration function:
public function up()
MySQL error (contains the generated SQL):
Error #1 - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL' at line 1. Failing Query: "ALTER TABLE my_table ADD new_field SET('value_a', 'value_b', 'value_c') DEFAULT NOT NULL"
After a bit of debugging I've found the problem, Doctrine_Formatter::quote() doesn't know how to handle set. Simply adding 'set' to the switch right below 'enum' will make it work as it should.
— lib/Doctrine/Formatter.php
+++ lib/Doctrine/Formatter.php
@@ -186,6 +186,7 @@ class Doctrine_Formatter extends Doctrine_Connection_Module
case 'blob':
case 'clob':
case 'enum':
+ case 'set':
case 'boolean':
return "'" . str_replace("'","''",$input) . "'";
}
Activity
| Field | Original Value | New Value |
|---|---|---|
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DMIG-2, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
I hope I put this into the right project, wasn't sure if this belonged in "Doctrine 1" but this project is called "Doctrine Migrations" so here it went.