doctrine/orm · error · LogicException

LimitSubqueryOutputWalker is to be used on SelectStatements

Error message

LimitSubqueryOutputWalker is to be used on SelectStatements only

What it means

Error "LimitSubqueryOutputWalker is to be used on SelectStatements only" thrown in doctrine/orm.

Source

Thrown at src/Tools/Pagination/LimitSubqueryOutputWalker.php:169

        // No need for an order by clause, we'll order by rownum in the outer query.
        $AST->orderByClause = null;
    }

    public function walkSelectStatement(SelectStatement $selectStatement): string
    {
        $sqlFinalizer = $this->getFinalizer($selectStatement);

        $query = $this->getQuery();

        $abstractSqlExecutor = $sqlFinalizer->createExecutor($query);

        return $abstractSqlExecutor->getSqlStatements();
    }

    public function getFinalizer(AST\DeleteStatement|AST\UpdateStatement|AST\SelectStatement $AST): SqlFinalizer
    {
        if (! $AST instanceof SelectStatement) {
            throw new LogicException(self::class . ' is to be used on SelectStatements only');
        }

        if ($this->platformSupportsRowNumber()) {
            $sql = $this->createSqlWithRowNumber($AST);
        } else {
            $sql = $this->createSqlWithoutRowNumber($AST);
        }

        return new SingleSelectSqlFinalizer($sql);
    }

    /**
     * Walks down a SelectStatement AST node, wrapping it in a SELECT DISTINCT.
     * This method is for use with platforms which support ROW_NUMBER.
     *
     * @throws RuntimeException
     */
    public function walkSelectStatementWithRowNumber(SelectStatement $AST): string

View on GitHub (pinned to d9b9ff7301)

When it happens

Trigger: Thrown at src/Tools/Pagination/LimitSubqueryOutputWalker.php:169 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of doctrine/orm@d9b9ff7301 (2026-08-21). Data as JSON: /api/errors/dd3759c60e75160f. Report an issue: GitHub.