Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use full table name with schema for SQLSRV #4058

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions system/Database/SQLSRV/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Builder extends BaseBuilder
*/
protected function _truncate(string $table): string
{
return 'TRUNCATE TABLE ' . $table;
return 'TRUNCATE TABLE ' . $this->getFullName($table);
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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) . ');';
}

/**
Expand Down Expand Up @@ -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');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/database/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down