Skip to content

Commit 019615c

Browse files
committed
cs
1 parent 9956410 commit 019615c

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

src/Database/Explorer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function queryArgs(string $sql, array $params): ResultSet
8181

8282
/**
8383
* Returns table selection.
84+
* @return Table\Selection<Table\ActiveRow>
8485
*/
8586
public function table(string $table): Table\Selection
8687
{

src/Database/Table/ActiveRow.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function ref(string $key, ?string $throughColumn = null): ?self
121121
*/
122122
public function related(string $key, ?string $throughColumn = null): GroupedSelection
123123
{
124-
$groupedSelection = $this->table->getReferencingTable($key, $throughColumn, $this[$this->table->getPrimary()]);
124+
$groupedSelection = $this->table->getReferencingTable($key, $throughColumn, $this->__get($this->table->getPrimary()));
125125
if (!$groupedSelection) {
126126
throw new Nette\MemberAccessException("No reference found for \${$this->table->getName()}->related($key).");
127127
}

src/Database/Table/SqlBuilder.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,21 @@ protected function addCondition(
315315
while (count($params)) {
316316
$arg = array_shift($params);
317317
preg_match(
318-
'#(?:.*?\?.*?){' . $placeholderNum . '}(((?:&|\||^|~|\+|-|\*|/|%|\(|,|<|>|=|(?<=\W|^)(?:REGEXP|ALL|AND|ANY|BETWEEN|EXISTS|IN|[IR]?LIKE|OR|NOT|SOME|INTERVAL))\s*)?(?:\(\?\)|\?))#s',
318+
'#
319+
(?:.*?\?.*?){' . $placeholderNum . '}
320+
(
321+
(
322+
(?:
323+
&|\||^|~|\+|-|\*|/|%|\(|,|<|>|=
324+
|
325+
(?<=\W|^)
326+
(?:REGEXP|ALL|AND|ANY|BETWEEN|EXISTS|IN|[IR]?LIKE|OR|NOT|SOME|INTERVAL)
327+
)
328+
\s*
329+
)?
330+
(?:\(\?\)|\?)
331+
)
332+
#xs',
319333
$condition,
320334
$match,
321335
PREG_OFFSET_CAPTURE,

tests/Database/Drivers/PgSqlDriver.formatLike.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ $connection->query('SET escape_string_warning TO off'); // do not log warnings
3333

3434
$connection->query('SET standard_conforming_strings TO on');
3535
$tests($connection);
36-
Assert::false($connection->query("SELECT 'AAxBB' LIKE", $connection::literal($driver->formatLike('A\\B', 0)))->fetchField());
37-
Assert::true($connection->query("SELECT 'AA\\BB' LIKE", $connection::literal($driver->formatLike('A\\B', 0)))->fetchField());
36+
Assert::false($connection->query("SELECT 'AAxBB' LIKE", $connection::literal($driver->formatLike('A\B', 0)))->fetchField());
37+
Assert::true($connection->query("SELECT 'AA\\BB' LIKE", $connection::literal($driver->formatLike('A\B', 0)))->fetchField());
3838

3939
$connection->query('SET standard_conforming_strings TO off');
4040
$tests($connection);
41-
Assert::false($connection->query("SELECT 'AAxBB' LIKE", $connection::literal($driver->formatLike('A\\B', 0)))->fetchField());
42-
Assert::true($connection->query("SELECT 'AA\\\\BB' LIKE", $connection::literal($driver->formatLike('A\\B', 0)))->fetchField());
41+
Assert::false($connection->query("SELECT 'AAxBB' LIKE", $connection::literal($driver->formatLike('A\B', 0)))->fetchField());
42+
Assert::true($connection->query("SELECT 'AA\\\\BB' LIKE", $connection::literal($driver->formatLike('A\B', 0)))->fetchField());

0 commit comments

Comments
 (0)