add LIMIT on update query #5937

Open
opened 2026-01-22 15:22:34 +01:00 by admin · 1 comment
Owner

Originally created by @safwanghamrawi on GitHub (Mar 29, 2018).

Originally assigned to: @safwanghamrawi on GitHub.

When we make an update query builder with setMaxResults to add LIMIT, the LIMIT is ignored in the class SqlWalker method walkUpdateStatement. Could we modify this function to be like:
`

/**
 * {@inheritdoc}
 */
public function walkUpdateStatement(AST\UpdateStatement $AST)
{
    $this->useSqlTableAliases = false;
    $this->rsm->isSelect      = false;
    $limit    = $this->query->getMaxResults();

    $sql = $this->walkUpdateClause($AST->updateClause)
        . $this->walkWhereClause($AST->whereClause);


    if ($limit !== null) {
        $sql = $this->platform->modifyLimitQuery($sql, $limit, null);
    }
    return $sql;
}
Originally created by @safwanghamrawi on GitHub (Mar 29, 2018). Originally assigned to: @safwanghamrawi on GitHub. When we make an update query builder with setMaxResults to add LIMIT, the LIMIT is ignored in the class SqlWalker method walkUpdateStatement. Could we modify this function to be like: ` /** * {@inheritdoc} */ public function walkUpdateStatement(AST\UpdateStatement $AST) { $this->useSqlTableAliases = false; $this->rsm->isSelect = false; $limit = $this->query->getMaxResults(); $sql = $this->walkUpdateClause($AST->updateClause) . $this->walkWhereClause($AST->whereClause); if ($limit !== null) { $sql = $this->platform->modifyLimitQuery($sql, $limit, null); } return $sql; }
admin added the BugMissing Tests labels 2026-01-22 15:22:34 +01:00
Author
Owner

@Ocramius commented on GitHub (Mar 29, 2018):

@safwanghamrawi a test case showing a failure caused by this is required before considering any fixes.

@Ocramius commented on GitHub (Mar 29, 2018): @safwanghamrawi a test case showing a failure caused by this is required before considering any fixes.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5937