Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ROW_NUMBER() in Mysql #453

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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

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