Doctrine 1
  1. Doctrine 1
  2. DC-202

Alias in InnerJoin-Update-Queries wrong

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Can't Fix
    • Affects Version/s: 1.0.13
    • Fix Version/s: None
    • Component/s: Query
    • Labels:
      None
    • Environment:
      Windows, Symfony 1.2.9

      Description

      I tried to do an UPDATE-Operation like the following example:

      $query = Doctrine_Query::create()
      ->update('PickingRequestStatus s')
      ->innerJoin('s.Request r')
      ->innerJoin('r.WorkStatus ws')
      ->set('s.status=?', PickingRequestStatus::$STATUS_WORK_CANCELLED)
      ->where('s.status = ?', array(PickingRequestStatus::$STATUS_WORK_STARTED))
      ->andWhere('ws.last_action_at < ?', $threshold);

      The created SQL-Statement is wrong:
      UPDATE sd_picking_request_status INNER JOIN sd_picking_request s2 ON s.request_id = s2.id INNER JOIN sd_picking_request_work_status s3 ON s2.id = s3.request_id SET status = 16 WHERE status = 8 AND last_action_at < '2009-11-08 11:00'

      and you will get the following error-message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 's.request_id' in 'on clause'

      If you remove the s. in the JOIN-Statement everthing is fine:

      UPDATE sd_picking_request_status INNER JOIN sd_picking_request s2 ON request_id = s2.id INNER JOIN sd_picking_request_work_status s3 ON s2.id = s3.request_id SET status = 16 WHERE status = 8 AND last_action_at < '2009-11-09 11:00'

        Activity

        Hide
        Jonathan H. Wage added a comment -

        This is one unfortunate limitation/issue with DELETE/UPDATE dql queries. You cannot perform any joins or anything. This works properly in Doctrine 2 though.

        Show
        Jonathan H. Wage added a comment - This is one unfortunate limitation/issue with DELETE/UPDATE dql queries. You cannot perform any joins or anything. This works properly in Doctrine 2 though.

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Timo Haberkern
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: