Doctrine 1
  1. Doctrine 1
  2. DC-230

CLONE [DC-197] default model orderBy option breaks data-load task

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-BETA2
    • Fix Version/s: 1.2.0-BETA3
    • Component/s: Data Fixtures
    • Labels:
      None

      Description

      currently the default orderBy clause one can specify for models gets added to all queries, including DELETE and UPDATE.
      This breaks data-load because it includes in the orderBy the table alias but currently only SELECT queries support aliases.

      For example if I have the following schema:

      Mytable:
      options:

      { orderBy: name ASC }

      columns:
      name:

      { type: string(100), notnull: true }

      The data-load task does a Doctrine::getTable('Mytable')>delete()>execute(); to clear the table before loading the fixtures which results in the following SQL:
      DELETE FROM mytable ORDER BY m.name ASC

      which errors out as the m alias was not defined.

      Attached is the patch that makes only SELECT queries get the default orderBy clause from the option.

        Activity

        Hide
        Miloslav "adrive" Kmet added a comment - - edited

        Sorry, if I did something wrong, but I do not found, how to reopen an issue in JIRA (stil not familiar with it.)

        I am using the latest 6725 revision of doctrine with sfDoctrinePlugin, but this issue still exists at least in posgresql:

        I have the following error:

        {{
        kmet@toox /www/dev/mis $ s doctrine:data-load

        >> doctrine Loading data fixtures from "/www/dev/mis/data/fixtures"

        SQLSTATE[42601]: Syntax error: 7 CHYBA: syntaktická chyba pri alebo v blízkosti "ORDER"

        LINE 1: DELETE FROM st_i18n_culture ORDER BY name ASC

        ^. Failing Query: "DELETE FROM st_i18n_culture ORDER BY name ASC"

        }}

        I am not using the orderBy: functionality in my models, but my model have the field "name".

        Show
        Miloslav "adrive" Kmet added a comment - - edited Sorry, if I did something wrong, but I do not found, how to reopen an issue in JIRA (stil not familiar with it.) I am using the latest 6725 revision of doctrine with sfDoctrinePlugin, but this issue still exists at least in posgresql: I have the following error: {{ kmet@toox /www/dev/mis $ s doctrine:data-load >> doctrine Loading data fixtures from "/www/dev/mis/data/fixtures" SQLSTATE [42601] : Syntax error: 7 CHYBA: syntaktická chyba pri alebo v blízkosti "ORDER" LINE 1: DELETE FROM st_i18n_culture ORDER BY name ASC ^. Failing Query: "DELETE FROM st_i18n_culture ORDER BY name ASC" }} I am not using the orderBy: functionality in my models, but my model have the field "name".

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Miloslav "adrive" Kmet
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: