-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Bug: Sqldrv problems to insert when change DBPrefix #3881
Comments
a table in SQL SERVER can not have . (dot) character in the compound of the name like sap. |
... and not have (dot) in the table name:
|
'DBPrefix' => 'sap.', that dot .. DBPrefix is used to ad a prefix to table name, in this case, sap. will generante sap.EndPoints as table name |
I currently have that same problem since the company where I work uses different schemes than dbo, which is why I have not been able to migrate from CI3, solution is 'prefix.' ? |
No, it is not the solution. When using a DBprefix other than dbo. a select, an update, works correctly, but when using an insert it fails. |
The solution we have adopted to be able to migrate to CI4 has been to change the prefix to dbo. in all tables |
cause this DBPrefix is not the dbo., it's a prefix to all name of tables, like: as you can see in the file system/Database/BaseConnection.php at line: 1347
|
This issue is related with the driver _insert funcion (on Builder.php): protected function _insert(string $table, array $keys, array $unescapedKeys): string
{
$fullTableName = $this->getFullName($table);
// insert statement
$statement = 'INSERT INTO ' . $fullTableName . ' (' . implode(',', $keys) . ') VALUES (' . implode(', ', $unescapedKeys) . ')';
return $this->keyPermission ? $this->addIdentity($fullTableName, $statement) : $statement;
} The issue is that only on _insert this happens, does not happen on _update or _delete So the quick fix woud be to replace $fullTableName with $table in the $statement inside _insert function. |
As mentioned earlier - If you check the user guide, you will find a Anyway, I feel like we need to use a full table name when it's possible to avoid confusion. |
CRITICAL - 2020-11-13 01:16:51 --> [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'sap.sap.EndPoints'.
duplicates DBPrefix when DBPrefix value is other than dbo.
It also does not take the value of schema
In App\Config\Database.php
public $development = [
'DSN' => '',
'hostname' => 'xxxxxxxxxxxx',
'username' => 'xxxxxxxxxxxx',
'password' => 'xxxxxxxxx',
'database' => 'develop',
'DBDriver' => 'sqlsrv',
'DBPrefix' => 'sap.',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => []
];
The text was updated successfully, but these errors were encountered: