You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (isset($this->aliases[$tableName]) && ('.' . $tableName === $chain)) {
360
+
$chain = $this->aliases[$tableName];
361
+
}
362
+
if (isset($this->reservedTableNames[$tableName])) {
363
+
if ($this->reservedTableNames[$tableName] === $chain) {
364
+
return;
365
+
}
366
+
thrownew \Nette\InvalidArgumentException("Table alias '$tableName' from chain '$chain' is already in use by chain '{$this->reservedTableNames[$tableName]}'. Please add/change alias for one of them.");
367
+
}
368
+
$this->reservedTableNames[$tableName] = $chain;
369
+
}
370
+
371
+
332
372
publicfunctionaddOrder($columns, ...$params)
333
373
{
334
374
$this->order[] = $columns;
@@ -448,15 +488,33 @@ public function parseJoinsCb(& $joins, $match)
448
488
// do not make a join when referencing to the current table column - inner conditions
449
489
// check it only when not making backjoin on itself - outer condition
thrownewNette\InvalidArgumentException("Do not prefix table chain with origin table name '{$keyMatches[0]['key']}'. If you want to make self reference, please add alias.");
}, Nette\InvalidArgumentException::class, "Table alias 'book1' from chain ':book' is already in use by chain ':book(translator)'. Please add/change alias for one of them.");
42
+
43
+
Assert::exception(function() use ($sqlBuilder) { // reserved by base table name
44
+
$sqlBuilder->addAlias(':book', 'author');
45
+
}, Nette\InvalidArgumentException::class, "Table alias 'author' from chain ':book' is already in use by chain 'author'. Please add/change alias for one of them.");
46
+
47
+
Assert::exception(function() use ($sqlBuilder) {
48
+
$sqlBuilder->addAlias(':book', 'book1');
49
+
}, Nette\InvalidArgumentException::class, "Table alias 'book1' from chain ':book' is already in use by chain ':book(translator)'. Please add/change alias for one of them.");
50
+
51
+
$sqlBuilder->addAlias(':book', 'tag');
52
+
Assert::exception(function() use ($sqlBuilder) {
53
+
$query = 'WHERE book1:book_tag.tag.id IS NULL';
54
+
$joins = [];
55
+
$sqlBuilder->parseJoins($joins, $query);
56
+
}, Nette\InvalidArgumentException::class, "Table alias 'tag' from chain '.book1:book_tag.tag' is already in use by chain ':book'. Please add/change alias for one of them.");
57
+
});
58
+
59
+
60
+
test(function() use ($context, $driver) { // test same table chain with another alias
0 commit comments