Skip to content

Commit

Permalink
fix table alias regexp in QueryHelper#cleanUpTableNames() (#371)
Browse files Browse the repository at this point in the history
* fix table alias regexp in QueryHelper#cleanUpTableNames()

Co-authored-by: Márton Somogyi <somogyi.marton@metrisoft.hu>
  • Loading branch information
kamarton and Márton Somogyi committed Oct 15, 2022
1 parent eb6f754 commit d1a99ef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Query/Helper/QueryHelper.php
Expand Up @@ -39,7 +39,7 @@ public function cleanUpTableNames(array $tableNames, QuoterInterface $quoter): a
{
$cleanedUpTableNames = [];
$pattern = <<<PATTERN
~^\s*((?:['"`\[]|{{).*?(?:['"`\]]|}})|\(.*?\)|.*?)(?:(?:\s+(?:as)?\s*)((?:['"`\[]|{{).*?(?:['"`\]]|}})|.*?))?\s*$~iux
~^\s*((?:['"`\[]|{{).*?(?:['"`\]]|}})|\(.*?\)|.*?)(?:(?:\s+(?:as\s+)?)((?:['"`\[]|{{).*?(?:['"`\]]|}})|.*?))?\s*$~iux
PATTERN;

/** @psalm-var array<array-key, Expression|string> $tableNames */
Expand Down
1 change: 1 addition & 0 deletions tests/QueryHelperTest.php
Expand Up @@ -18,6 +18,7 @@ public function tablesNameDataProvider(): array
return [
[['customer'], '', ['{{customer}}' => '{{customer}}']],
[['profile AS "prf"'], '', ['{{prf}}' => '{{profile}}']],
[['mainframe as400'], '', ['{{as400}}' => '{{mainframe}}']],
[
['x' => new Expression('(SELECT id FROM user)')],
'',
Expand Down

0 comments on commit d1a99ef

Please sign in to comment.