Skip to content

Commit 509bc53

Browse files
committed
Engine::delimite() -> delimit() (BC break)
1 parent 9d3ef35 commit 509bc53

File tree

14 files changed

+57
-56
lines changed

14 files changed

+57
-56
lines changed

src/Database/Drivers/Engine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function convertToPhp(mixed $value, array $meta, TypeConverter $converter): mixe
4040
/********************* SQL utilities ****************d*g**/
4141

4242
/** Adds delimiters around database identifier. */
43-
function delimite(string $name): string;
43+
function delimit(string $name): string;
4444

4545
/** Formats a date-time value for use in an SQL statement. */
4646
function formatDateTime(\DateTimeInterface $value): string;

src/Database/Drivers/Engines/MSSQLEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function classifyException(Nette\Database\DriverException $e): ?string
4242
/********************* SQL ****************d*g**/
4343

4444

45-
public function delimite(string $name): string
45+
public function delimit(string $name): string
4646
{
4747
// @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
4848
return '[' . str_replace(['[', ']'], ['[[', ']]'], $name) . ']';

src/Database/Drivers/Engines/MySQLEngine.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function classifyException(Nette\Database\DriverException $e): ?string
5353
/********************* SQL ****************d*g**/
5454

5555

56-
public function delimite(string $name): string
56+
public function delimit(string $name): string
5757
{
5858
// @see http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
5959
return '`' . str_replace('`', '``', $name) . '`';
@@ -115,7 +115,7 @@ public function getTables(): array
115115
public function getColumns(string $table): array
116116
{
117117
$columns = [];
118-
$rows = $this->connection->query('SHOW FULL COLUMNS FROM ' . $this->delimite($table));
118+
$rows = $this->connection->query('SHOW FULL COLUMNS FROM ' . $this->delimit($table));
119119
while ($row = $rows->fetch()) {
120120
$row = array_change_key_case($row);
121121
$typeInfo = Nette\Database\Helpers::parseColumnType($row['type']);
@@ -141,7 +141,7 @@ public function getColumns(string $table): array
141141
public function getIndexes(string $table): array
142142
{
143143
$indexes = [];
144-
$rows = $this->connection->query('SHOW INDEX FROM ' . $this->delimite($table));
144+
$rows = $this->connection->query('SHOW INDEX FROM ' . $this->delimit($table));
145145
while ($row = $rows->fetch()) {
146146
$id = $row['Key_name'];
147147
$indexes[$id]['name'] = $id;

src/Database/Drivers/Engines/ODBCEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function classifyException(Nette\Database\DriverException $e): ?string
3535
/********************* SQL ****************d*g**/
3636

3737

38-
public function delimite(string $name): string
38+
public function delimit(string $name): string
3939
{
4040
return '[' . str_replace(['[', ']'], ['[[', ']]'], $name) . ']';
4141
}

src/Database/Drivers/Engines/OracleEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function classifyException(Nette\Database\DriverException $e): ?string
5151
/********************* SQL ****************d*g**/
5252

5353

54-
public function delimite(string $name): string
54+
public function delimit(string $name): string
5555
{
5656
// @see http://download.oracle.com/docs/cd/B10500_01/server.920/a96540/sql_elements9a.htm
5757
return '"' . str_replace('"', '""', $name) . '"';

src/Database/Drivers/Engines/PostgreSQLEngine.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function classifyException(Nette\Database\DriverException $e): ?string
4949
/********************* SQL ****************d*g**/
5050

5151

52-
public function delimite(string $name): string
52+
public function delimit(string $name): string
5353
{
5454
// @see http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
5555
return '"' . str_replace('"', '""', $name) . '"';
@@ -156,7 +156,7 @@ public function getColumns(string $table): array
156156
AND NOT a.attisdropped
157157
ORDER BY
158158
a.attnum
159-
X, [$this->delimiteFQN($table)]);
159+
X, [$this->delimitFQN($table)]);
160160

161161
while ($row = $rows->fetch()) {
162162
$column = $row;
@@ -187,7 +187,7 @@ public function getIndexes(string $table): array
187187
WHERE
188188
c1.relkind IN ('r', 'p')
189189
AND c1.oid = ?::regclass
190-
X, [$this->delimiteFQN($table)]);
190+
X, [$this->delimitFQN($table)]);
191191

192192
while ($row = $rows->fetch()) {
193193
$id = $row['name'];
@@ -222,7 +222,7 @@ public function getForeignKeys(string $table): array
222222
co.contype = 'f'
223223
AND cl.oid = ?::regclass
224224
AND nf.nspname = ANY (pg_catalog.current_schemas(FALSE))
225-
X, [$this->delimiteFQN($table)]);
225+
X, [$this->delimitFQN($table)]);
226226

227227
while ($row = $rows->fetch()) {
228228
$id = $row['name'];
@@ -247,8 +247,8 @@ public function convertToPhp(mixed $value, array $meta, TypeConverter $converter
247247
/**
248248
* Converts: schema.name => "schema"."name"
249249
*/
250-
private function delimiteFQN(string $name): string
250+
private function delimitFQN(string $name): string
251251
{
252-
return implode('.', array_map([$this, 'delimite'], explode('.', $name)));
252+
return implode('.', array_map([$this, 'delimit'], explode('.', $name)));
253253
}
254254
}

src/Database/Drivers/Engines/SQLServerEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function classifyException(Nette\Database\DriverException $e): ?string
4242
/********************* SQL ****************d*g**/
4343

4444

45-
public function delimite(string $name): string
45+
public function delimit(string $name): string
4646
{
4747
/** @see https://msdn.microsoft.com/en-us/library/ms176027.aspx */
4848
return '[' . str_replace(']', ']]', $name) . ']';

src/Database/Drivers/Engines/SQLiteEngine.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function classifyException(Nette\Database\DriverException $e): ?string
7171
/********************* SQL ****************d*g**/
7272

7373

74-
public function delimite(string $name): string
74+
public function delimit(string $name): string
7575
{
7676
return '[' . strtr($name, '[]', ' ') . ']';
7777
}
@@ -145,7 +145,7 @@ public function getColumns(string $table): array
145145
X, [$table, $table])->fetch();
146146

147147
$columns = [];
148-
$rows = $this->connection->query("PRAGMA table_info({$this->delimite($table)})");
148+
$rows = $this->connection->query("PRAGMA table_info({$this->delimit($table)})");
149149
while ($row = $rows->fetch()) {
150150
$column = $row['name'];
151151
$pattern = "/(\"$column\"|`$column`|\\[$column\\]|$column)\\s+[^,]+\\s+PRIMARY\\s+KEY\\s+AUTOINCREMENT/Ui";
@@ -172,7 +172,7 @@ public function getColumns(string $table): array
172172
public function getIndexes(string $table): array
173173
{
174174
$indexes = [];
175-
$rows = $this->connection->query("PRAGMA index_list({$this->delimite($table)})");
175+
$rows = $this->connection->query("PRAGMA index_list({$this->delimit($table)})");
176176
while ($row = $rows->fetch()) {
177177
$id = $row['name'];
178178
$indexes[$id]['name'] = $id;
@@ -181,7 +181,7 @@ public function getIndexes(string $table): array
181181
}
182182

183183
foreach ($indexes as $index => $values) {
184-
$res = $this->connection->query("PRAGMA index_info({$this->delimite($index)})");
184+
$res = $this->connection->query("PRAGMA index_info({$this->delimit($index)})");
185185
while ($row = $res->fetch()) {
186186
$indexes[$index]['columns'][] = $row['name'];
187187
}
@@ -219,7 +219,7 @@ public function getIndexes(string $table): array
219219
public function getForeignKeys(string $table): array
220220
{
221221
$keys = [];
222-
$rows = $this->connection->query("PRAGMA foreign_key_list({$this->delimite($table)})");
222+
$rows = $this->connection->query("PRAGMA foreign_key_list({$this->delimit($table)})");
223223
while ($row = $rows->fetch()) {
224224
$id = $row['id'];
225225
$keys[$id]['name'] = $id;

src/Database/SqlPreprocessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,6 @@ private function formatLiteral(SqlLiteral $value): string
352352
*/
353353
private function delimit(string $name): string
354354
{
355-
return implode('.', array_map($this->engine->delimite(...), explode('.', $name)));
355+
return implode('.', array_map($this->engine->delimit(...), explode('.', $name)));
356356
}
357357
}

src/Database/Table/Selection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ public function insert(iterable $data): ActiveRow|array|int|bool
812812

813813
// First check sequence
814814
if (!empty($primarySequenceName) && $primaryAutoincrementKey) {
815-
$primaryKey[$primaryAutoincrementKey] = $this->explorer->getInsertId($this->explorer->getDatabaseEngine()->delimite($primarySequenceName));
815+
$primaryKey[$primaryAutoincrementKey] = $this->explorer->getInsertId($this->explorer->getDatabaseEngine()->delimit($primarySequenceName));
816816

817817
// Autoincrement primary without sequence
818818
} elseif ($primaryAutoincrementKey) {

0 commit comments

Comments
 (0)