-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test according to main PR (#293)
Co-authored-by: Sergei Predvoditelev <[email protected]>
- Loading branch information
Showing
9 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Mssql\Builder; | ||
|
||
use Yiisoft\Db\Expression\AbstractExpressionBuilder; | ||
use Yiisoft\Db\Mssql\SqlParser; | ||
|
||
final class ExpressionBuilder extends AbstractExpressionBuilder | ||
{ | ||
protected function createSqlParser(string $sql): SqlParser | ||
{ | ||
return new SqlParser($sql); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Mssql; | ||
|
||
use Yiisoft\Db\Syntax\AbstractSqlParser; | ||
|
||
final class SqlParser extends AbstractSqlParser | ||
{ | ||
public function getNextPlaceholder(int|null &$position = null): string|null | ||
{ | ||
$result = null; | ||
$length = $this->length - 1; | ||
|
||
while ($this->position < $length) { | ||
Check warning on line 16 in src/SqlParser.php GitHub Actions / PHP 8.1-ubuntu-latest
|
||
$pos = $this->position++; | ||
|
||
match ($this->sql[$pos]) { | ||
':' => ($word = $this->parseWord()) === '' | ||
? $this->skipChars(':') | ||
: $result = ':' . $word, | ||
'"', "'" => $this->skipQuotedWithoutEscape($this->sql[$pos]), | ||
'[' => $this->sql[$this->position] === '[' | ||
? $this->skipToAfterString(']]') | ||
: $this->skipQuotedWithoutEscape(']'), | ||
'-' => $this->sql[$this->position] === '-' | ||
? ++$this->position && $this->skipToAfterChar("\n") | ||
Check warning on line 28 in src/SqlParser.php GitHub Actions / PHP 8.1-ubuntu-latest
Check warning on line 28 in src/SqlParser.php GitHub Actions / PHP 8.1-ubuntu-latest
Check warning on line 28 in src/SqlParser.php GitHub Actions / PHP 8.1-ubuntu-latest
|
||
: null, | ||
'/' => $this->sql[$this->position] === '*' | ||
? ++$this->position && $this->skipToAfterString('*/') | ||
Check warning on line 31 in src/SqlParser.php GitHub Actions / PHP 8.1-ubuntu-latest
Check warning on line 31 in src/SqlParser.php GitHub Actions / PHP 8.1-ubuntu-latest
Check warning on line 31 in src/SqlParser.php GitHub Actions / PHP 8.1-ubuntu-latest
|
||
: null, | ||
default => null, | ||
}; | ||
|
||
if ($result !== null) { | ||
$position = $pos; | ||
|
||
return $result; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Mssql\Tests\Provider; | ||
|
||
class SqlParserProvider extends \Yiisoft\Db\Tests\Provider\SqlParserProvider | ||
{ | ||
public static function getNextPlaceholder(): array | ||
{ | ||
return [ | ||
...parent::getNextPlaceholder(), | ||
[ | ||
'[:field] = :name AND age = :age', | ||
':name', | ||
11, | ||
], | ||
[ | ||
'[[:field]] = :name AND age = :age', | ||
':name', | ||
13, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Mssql\Tests; | ||
|
||
use Yiisoft\Db\Mssql\SqlParser; | ||
use Yiisoft\Db\Tests\AbstractSqlParserTest; | ||
|
||
/** | ||
* @group mssql | ||
*/ | ||
final class SqlParserTest extends AbstractSqlParserTest | ||
{ | ||
protected function createSqlParser(string $sql): SqlParser | ||
{ | ||
return new SqlParser($sql); | ||
} | ||
|
||
/** @dataProvider \Yiisoft\Db\Mssql\Tests\Provider\SqlParserProvider::getNextPlaceholder */ | ||
public function testGetNextPlaceholder(string $sql, string|null $expectedPlaceholder, int|null $expectedPosition): void | ||
{ | ||
parent::testGetNextPlaceholder($sql, $expectedPlaceholder, $expectedPosition); | ||
} | ||
} |