Bug #28184

Unable to create database if entity contains member "read"

Added by Michael Klapper over 10 years ago. Updated almost 10 years ago.

Status:
Rejected
Priority:
Should have
Category:
Persistence
Target version:
-
Start date:
2011-07-13
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

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.

#2

Updated by Alexander Berl almost 10 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 almost 10 years ago

  • Category set to Persistence
  • Status changed from New to Rejected
  • Assignee 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")

Also available in: Atom PDF