Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-148

Foreign key creation fails with MySQL 5.1.54

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1
    • Component/s: None
    • Labels:
      None
    • Environment:
      MySQL 5.1.54, PHP 5.3.5, Ubuntu 11.04, Zend Framework 1.11.10

      Description

      doctrine orm:schema-tool:create

      returns

      [PDOException]
      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 'Position(id)' at line 1

      The problem seem to be that the create commande creates the following SQL syntax
      ALTER TABLE Job ADD FOREIGN KEY (position_id) REFERENCES Position(id);

      which doesn't work. If I use the following (added a space between Postion and (id) in the end) it works.
      ALTER TABLE Job ADD FOREIGN KEY (position_id) REFERENCES Position (id);

      Patch for AbstractPlatform.php attached.

      1. git_commit_9242fb332baaaeb81be4.txt
        0.4 kB
        Frej Connolly
      2. Job.php
        0.9 kB
        Frej Connolly
      3. orm_schema-tool_create--dump-sql.txt
        1 kB
        Frej Connolly
      4. Position.php
        0.4 kB
        Frej Connolly

        Activity

        Frej Connolly created issue -
        Frej Connolly made changes -
        Field Original Value New Value
        Attachment git_commit_9242fb332baaaeb81be4.txt [ 11055 ]
        Frej Connolly made changes -
        Description doctrine orm:schema-tool:create

        returns

        [PDOException]
        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 'Position(id)' at line 1

        The problem seem to be that the create commande creates the following SQL syntax
        ALTER TABLE Job ADD FOREIGN KEY (position_id) REFERENCES Position(id);

        which doesn't work. If I use the following (added a space between Postion and (id) in the end) it works.
        ALTER TABLE Job ADD FOREIGN KEY (position_id) REFERENCES Position (id);
        doctrine orm:schema-tool:create

        returns

        [PDOException]
        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 'Position(id)' at line 1

        The problem seem to be that the create commande creates the following SQL syntax
        ALTER TABLE Job ADD FOREIGN KEY (position_id) REFERENCES Position(id);

        which doesn't work. If I use the following (added a space between Postion and (id) in the end) it works.
        ALTER TABLE Job ADD FOREIGN KEY (position_id) REFERENCES Position (id);

        Patch for AbstractPlatform.php attached.
        Fix Version/s 2.1 [ 10068 ]
        Hide
        Benjamin Eberlei added a comment -

        Fixed and merged 2.1.x

        Show
        Benjamin Eberlei added a comment - Fixed and merged 2.1.x
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 12926 ] jira-feedback2 [ 17742 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17742 ] jira-feedback3 [ 20097 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • 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=DBAL-148, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Frej Connolly
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: