diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php index 932d8156e494..be26086c4538 100755 --- a/system/Database/SQLSRV/Builder.php +++ b/system/Database/SQLSRV/Builder.php @@ -76,7 +76,7 @@ class Builder extends BaseBuilder */ protected function _truncate(string $table): string { - return 'TRUNCATE TABLE ' . $table; + return 'TRUNCATE TABLE ' . $this->getFullName($table); } /** @@ -122,10 +122,12 @@ protected function _update(string $table, array $values): string $valstr[] = $key . ' = ' . $val; } - $statement = 'UPDATE ' . (empty($this->QBLimit) ? '' : 'TOP(' . $this->QBLimit . ') ') . $table . ' SET ' + $fullTableName = $this->getFullName($table); + + $statement = 'UPDATE ' . (empty($this->QBLimit) ? '' : 'TOP(' . $this->QBLimit . ') ') . $fullTableName . ' SET ' . implode(', ', $valstr) . $this->compileWhereHaving('QBWhere') . $this->compileOrderBy(); - return $this->keyPermission ? $this->addIdentity($this->getFullName($table), $statement) : $statement; + return $this->keyPermission ? $this->addIdentity($fullTableName, $statement) : $statement; } /** @@ -355,7 +357,7 @@ protected function _replace(string $table, array $keys, array $values): string return $this->db->escapeIdentifiers($item); }, $keyFields); - return 'INSERT INTO ' . $table . ' (' . implode(',', $keys) . ') VALUES (' . implode(',', $values) . ');'; + return 'INSERT INTO ' . $this->getFullName($table) . ' (' . implode(',', $keys) . ') VALUES (' . implode(',', $values) . ');'; } /** @@ -409,7 +411,7 @@ protected function maxMinAvgSum(string $select = '', string $alias = '', string */ protected function _delete(string $table): string { - return 'DELETE' . (empty($this->QBLimit) ? '' : ' TOP (' . $this->QBLimit . ') ') . ' FROM ' . $table . $this->compileWhereHaving('QBWhere'); + return 'DELETE' . (empty($this->QBLimit) ? '' : ' TOP (' . $this->QBLimit . ') ') . ' FROM ' . $this->getFullName($table) . $this->compileWhereHaving('QBWhere'); } /** diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index d4d48e62655e..ac858c9ec950 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -198,7 +198,7 @@ Explanation of Values: **swapPre** A default table prefix that should be swapped with dbprefix. This is useful for distributed applications where you might run manually written queries, and need the prefix to still be customizable by the end user. -**schema** The database schema, defaults to 'public'. Used by PostgreSQL and ODBC drivers. +**schema** The database schema, default value varies by driver. Used by PostgreSQL and SQLSRV drivers. **encrypt** Whether or not to use an encrypted connection. - 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE