Skip to content
Merged
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
22 changes: 20 additions & 2 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Yiisoft\Db\Pgsql\Tests;

use Closure;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\DataProviderExternal;
use PHPUnit\Framework\Attributes\TestWith;
Expand Down Expand Up @@ -686,8 +687,6 @@ public static function dataBuildIdentifier(): iterable
yield ['s.t.name', '"s"."t"."name"'];
yield [['t', 'na.me'], '"t"."na.me"'];
yield ['LOWER(name)', '"LOWER(name)"'];
yield ['[[name]]', '"[[name]]"'];
yield ['{{%t}}.name', '"{{%t}}"."name"'];
yield ['*', '"*"'];
yield ['arr[1]', '"arr[1]"'];
yield ['a"b', '"a""b"'];
Expand All @@ -701,4 +700,23 @@ public function testBuildIdentifier(string|array $name, string $expected): void

$this->assertSame($expected, $qb->buildExpression(new Identifier($name)));
}

public static function dataBuildIdentifierWithQuoteSqlSequences(): iterable
{
yield ['[[name]]', '"[[name]]"'];
yield ['{{%t}}.name', '"{{%t}}"."name"'];
}

#[DataProvider('dataBuildIdentifierWithQuoteSqlSequences')]
public function testBuildIdentifierWithQuoteSqlSequences(string|array $name, string $expected): void
{
$qb = $this->getSharedConnection()->getQueryBuilder();

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
'Identifier ' . $expected . ' must not contain sequences processed by '
. '"Yiisoft\\Db\\Schema\\QuoterInterface::quoteSql()", such as "[[...]]" or "{{...}}".',
);
$qb->buildExpression(new Identifier($name));
}
}
Loading