Bug #28184
Unable to create database if entity contains member "read"
Status: | Rejected | Start date: | 2011-07-13 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Karsten Dambekalns | % Done: | 0% |
|
Category: | Persistence | |||
Target version: | - | |||
PHP Version: | Complexity: | |||
Has patch: | No | Affected Flow version: | FLOW3 1.0.0 |
Description
/** * @scope prototype * @entity */ class MyModel { /** * @var boolean */ protected $read = false; ... }
Error message
$ ./flow3 typo3.flow3:doctrine:create Uncaught Exception in FLOW3 #42000: 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 'read TINYINT(1) DEFAULT NULL, author VARCHAR(255) DEFAULT NULL, datetime DATETIM' at line 1 thrown in file Packages/Framework/Doctrine/Classes/DBAL/Connection.php in line 618 #0 TYPO3\FLOW3\Error\DebugExceptionHandler::echoExceptionCli() /var/www/project/Packages/Framework/TYPO3/FLOW3/Classes/Error/AbstractExceptionHandler.php:60 #1 TYPO3\FLOW3\Error\AbstractExceptionHandler::handleException()
When i rename the member from "$read;" into "$wasRead" every thing works as expected.
History
#1 Updated by Karsten Dambekalns almost 4 years ago
- Affected Flow version set to FLOW3 1.0.0
#2 Updated by Alexander Berl over 3 years ago
The error is in the SQL CREATE/ALTER query, where the column names should get quoted with ` or prefixed with the table identifier to prevent them from matching to keywords (like READ).
See http://dev.mysql.com/doc/refman/5.6/en/reserved-words.html
The bug is within Doctrine but I could not find a matching issue in the issue tracker (http://www.doctrine-project.org/jira/secure/IssueNavigator.jspa?) with a quick search.
#3 Updated by Karsten Dambekalns over 3 years ago
- Category set to Persistence
- Status changed from New to Rejected
- Assigned To set to Karsten Dambekalns
- Has patch set to No
The solution that is also recommended by the Doctrine people is to not use reserved words. You can specify another column name for a field using
@ORM\Column(name="isread")