doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.94k stars 2.52k forks source link

add LIMIT on update query #7164

Open safwanghamrawi opened 6 years ago

safwanghamrawi commented 6 years ago

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;
}
Ocramius commented 6 years ago

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