Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Invalid
-
Affects Version/s: 1.2.0, 1.2.1
-
Fix Version/s: None
-
Component/s: Migrations
-
Labels:None
-
Environment:LAMP
Description
I discovered this whilst trying out migrations via symfony. I added a datetime field to my schema.yml and generated the migrations, but upon running the migration I got the following error:
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 '()' at line 1. Failing Query: "ALTER TABLE order_item ADD purchased_at datetime()"
The following code causes the failure in the actual migration:
$this->addColumn('order_item', 'purchased_at', 'datetime', '', array());
because it generates the following sql:
ALTER TABLE order_item ADD purchased_at datetime()
The diff from my patched version which fixes the issue is as follows:
Index: Doctrine/DataDict/Mysql.php
===================================================================
— Doctrine/DataDict/Mysql.php (revision 7415)
+++ Doctrine/DataDict/Mysql.php (working copy)
@@ -227,6 +227,7 @@
return 'DATE';
case 'time':
return 'TIME';
+ case 'datetime':
case 'timestamp':
return 'DATETIME';
case 'float':
It's against the following repository file:
http://doctrine.mirror.svn.symfony-project.com/branches/1.2/lib/Doctrine/DataDict/Mysql.php
I hope this is useful and gets committed ![]()
Activity
| Field | Original Value | New Value |
|---|---|---|
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Invalid [ 6 ] |
- 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=DC-582, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
I've just discovered that the same issue exists for fields of type 'text':
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, session_time DATETIME NOT NULL, INDEX session_id_index_idx (session_' at line 1. Failing Query: "CREATE TABLE session (id BIGINT AUTO_INCREMENT, session_id VARCHAR(64) NOT NULL, session_data text() NOT NULL, session_time DATETIME NOT NULL, INDEX session_id_index_idx (session_id), PRIMARY KEY(id)) ENGINE = INNODB"
from the following schema:
Session:
{ type: string(64), notnull: true }columns:
session_id:
session_data:
{ type: text, notnull: true }session_time:
{ type: timestamp, notnull: true }indexes:
session_id_index:
fields: [ session_id ]
unique: true
I guess there may be other field entries missing too. Is there a comprehensive list of doctrine field types somewhere?