Doctrine 1
  1. Doctrine 1
  2. DC-322

Data dump fails on tables with quoted identifiers

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: Data Fixtures
    • Labels:
      None
    • Environment:
      linux, apache 2, mysql 5.1, php 5.2

      Description

      While dumping a table with a quoted identifier `numeric`, doctrine failed because the constructed query had an invalid alias the field: c__`numeric`.

      Output:
      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 '`numeric`, c.alpha3 AS c_alpha3, c.alpha2 AS calpha2 FROM country_codes c' at line 1. Failing Query: "SELECT c.country AS ccountry, c.`numeric` AS c`numeric`, c.alpha3 AS calpha3, c.alpha2 AS c_alpha2 FROM country_codes c"

      I know that using quoted identifiers is discouraged but I think this could be easily solvable.

      Thanks.

        Activity

        Hide
        Juozas Kaziukenas added a comment -

        However, variables cannot be quoted like that - quoting happens after actual columns are constructed, so now Doctrine needs to unquote it and do it's stuff. If you want quoting - enable that option and it will do it for you, or the best - don't use reserved words in your schema

        This issue can be closed as Invalid.

        Show
        Juozas Kaziukenas added a comment - However, variables cannot be quoted like that - quoting happens after actual columns are constructed, so now Doctrine needs to unquote it and do it's stuff. If you want quoting - enable that option and it will do it for you, or the best - don't use reserved words in your schema This issue can be closed as Invalid.
        Hide
        Massimiliano Torromeo added a comment -

        I'm not using Doctrine::ATTR_QUOTE_IDENTIFIER, I generated a yaml from a preexisting db and then adapted it.

        It generated the following definition:
        CountryCodes:
        columns:
        country:
        type: string(32)
        notnull: true
        `numeric`:
        type: integer(2)
        unsigned: 1
        primary: true
        alpha3:
        type: string(3)
        fixed: true
        notnull: true
        alpha2:
        type: string(2)
        fixed: true
        notnull: true

        but it was with an old version of Doctrine and this is not the case anymore (I tried regenerating it). I assumed it was correct to quote one single identifier, but I now guess it wasn't.

        I think this can be closed as NotBug.

        Sorry for the trouble.
        Regards.

        Show
        Massimiliano Torromeo added a comment - I'm not using Doctrine::ATTR_QUOTE_IDENTIFIER, I generated a yaml from a preexisting db and then adapted it. It generated the following definition: CountryCodes: columns: country: type: string(32) notnull: true `numeric`: type: integer(2) unsigned: 1 primary: true alpha3: type: string(3) fixed: true notnull: true alpha2: type: string(2) fixed: true notnull: true but it was with an old version of Doctrine and this is not the case anymore (I tried regenerating it). I assumed it was correct to quote one single identifier, but I now guess it wasn't. I think this can be closed as NotBug. Sorry for the trouble. Regards.
        Hide
        Juozas Kaziukenas added a comment -

        In which code part are you quoting that column? Because just enabling identifiers quoting would result in completely different results (at least there will be all columns quotes or none).

        Show
        Juozas Kaziukenas added a comment - In which code part are you quoting that column? Because just enabling identifiers quoting would result in completely different results (at least there will be all columns quotes or none).

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Massimiliano Torromeo
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: