Skip to content

Commit 71a2a64

Browse files
committed
Add alias exception for Postgres and SQLite
These are forced by DB to always be referred to as "excluded". A custom alias cannot be set.
1 parent 9028bba commit 71a2a64

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

system/Database/Postgre/Builder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,11 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
364364
}
365365
}
366366

367-
$alias = '"excluded"';
367+
$alias = $this->QBOptions['alias'] ?? '"excluded"';
368+
369+
if (strtolower($alias) !== '"excluded"' && $this->db->DBDebug) {
370+
throw new DatabaseException('Postgres alias is always named "excluded". A custom alias cannot be used.');
371+
}
368372

369373
$updateFields = $this->QBOptions['updateFields'] ?? $this->updateFields($keys, false, $constraints)->QBOptions['updateFields'] ?? [];
370374

system/Database/SQLite3/Builder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
164164
return ''; // @codeCoverageIgnore
165165
}
166166

167-
$alias = '`excluded`';
167+
$alias = $this->QBOptions['alias'] ?? '`excluded`';
168+
169+
if (strtolower($alias) !== '"excluded"' && $this->db->DBDebug) {
170+
throw new DatabaseException('SQLite alias is always named "excluded". A custom alias cannot be used.');
171+
}
168172

169173
$updateFields = $this->QBOptions['updateFields'] ??
170174
$this->updateFields($keys, false, $constraints)->QBOptions['updateFields'] ??

0 commit comments

Comments
 (0)