Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Query/Mysql/RowNumber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

class RowNumber extends FunctionNode
{
public function getSql(SqlWalker $sqlWalker): string
{
return 'ROW_NUMBER()';
}

public function parse(Parser $parser): void
{
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
16 changes: 16 additions & 0 deletions tests/Query/Mysql/RowNumberTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace DoctrineExtensions\Tests\Query\Mysql;

use DoctrineExtensions\Tests\Query\MysqlTestCase;

class RowNumberTest extends MysqlTestCase
{
public function testRowNumber(): void
{
$this->assertDqlProducesSql(
'SELECT ROW_NUMBER() from DoctrineExtensions\Tests\Entities\Blank b',
'SELECT ROW_NUMBER() AS sclr_0 FROM Blank b0_'
);
}
}