Skip to content

Commit

Permalink
Add ROW_NUMBER() in Mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
n0099 authored Oct 5, 2024
1 parent 2e24c3d commit b42369f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
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

Check failure on line 1 in src/Query/Mysql/RowNumber.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (8.3)

End of line character is invalid; expected "\n" but found "\r\n"

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

Check failure on line 1 in tests/Query/Mysql/RowNumberTest.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (8.3)

End of line character is invalid; expected "\n" but found "\r\n"

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_'
);
}
}

0 comments on commit b42369f

Please sign in to comment.