Skip to content

Commit eeaff9e

Browse files
committed
Use full table name with schema for SQLSRV
1 parent 659be22 commit eeaff9e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

system/Database/SQLSRV/Builder.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Builder extends BaseBuilder
7676
*/
7777
protected function _truncate(string $table): string
7878
{
79-
return 'TRUNCATE TABLE ' . $table;
79+
return 'TRUNCATE TABLE ' . $this->getFullName($table);
8080
}
8181

8282
/**
@@ -122,10 +122,12 @@ protected function _update(string $table, array $values): string
122122
$valstr[] = $key . ' = ' . $val;
123123
}
124124

125-
$statement = 'UPDATE ' . (empty($this->QBLimit) ? '' : 'TOP(' . $this->QBLimit . ') ') . $table . ' SET '
125+
$fullTableName = $this->getFullName($table);
126+
127+
$statement = 'UPDATE ' . (empty($this->QBLimit) ? '' : 'TOP(' . $this->QBLimit . ') ') . $fullTableName . ' SET '
126128
. implode(', ', $valstr) . $this->compileWhereHaving('QBWhere') . $this->compileOrderBy();
127129

128-
return $this->keyPermission ? $this->addIdentity($this->getFullName($table), $statement) : $statement;
130+
return $this->keyPermission ? $this->addIdentity($fullTableName, $statement) : $statement;
129131
}
130132

131133
/**
@@ -355,7 +357,7 @@ protected function _replace(string $table, array $keys, array $values): string
355357
return $this->db->escapeIdentifiers($item);
356358
}, $keyFields);
357359

358-
return 'INSERT INTO ' . $table . ' (' . implode(',', $keys) . ') VALUES (' . implode(',', $values) . ');';
360+
return 'INSERT INTO ' . $this->getFullName($table) . ' (' . implode(',', $keys) . ') VALUES (' . implode(',', $values) . ');';
359361
}
360362

361363
/**
@@ -409,7 +411,7 @@ protected function maxMinAvgSum(string $select = '', string $alias = '', string
409411
*/
410412
protected function _delete(string $table): string
411413
{
412-
return 'DELETE' . (empty($this->QBLimit) ? '' : ' TOP (' . $this->QBLimit . ') ') . ' FROM ' . $table . $this->compileWhereHaving('QBWhere');
414+
return 'DELETE' . (empty($this->QBLimit) ? '' : ' TOP (' . $this->QBLimit . ') ') . ' FROM ' . $this->getFullName($table) . $this->compileWhereHaving('QBWhere');
413415
}
414416

415417
/**

user_guide_src/source/database/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Explanation of Values:
198198
**swapPre** A default table prefix that should be swapped with dbprefix. This is useful for distributed
199199
applications where you might run manually written queries, and need the prefix to still be
200200
customizable by the end user.
201-
**schema** The database schema, defaults to 'public'. Used by PostgreSQL and ODBC drivers.
201+
**schema** The database schema, default value varies by driver. Used by PostgreSQL and SQLSRV drivers.
202202
**encrypt** Whether or not to use an encrypted connection.
203203

204204
- 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE

0 commit comments

Comments
 (0)