Quoting behaves not as expected
modir opened this issue · 4 comments
Bug Report
| Version(s) | 2.13.4
Current behavior
We have here an MSSQL database were we run these statements against:
$select = new Select();
$select->from($this->tableGateway->getTable());
$select->columns(['Code', 'Description'])
->where([$platform->quoteIdentifier('Promotional Order Active') => '1'])
->order('Description');
// for debugging
$sql = new Sql($this->tableGateway->getAdapter());
$statement = $sql->prepareStatementForSqlObject($select);
print_r($statement->getSql());
the output is then this SQL statement:
SELECT [Company CH$Brand Product Line].[Code] AS [Code], [Company CH$Brand Product Line].[Description] AS [Description] FROM [Company CH$Brand Product Line] WHERE [\][Company] [CH$Brand] [Product] [Line].[Promotional] [Order] [Active][]] = :where1 ORDER BY [Description] ASC
As you can see there are wrong quotings after the WHERE. Once the backslash, then each word with a quote instead of all together and then at the end empty brackets.
Expected behavior
I would have expected to be like this:
SELECT [Company CH$Brand Product Line].[Code] AS [Code], [Company CH$Brand Product Line].[Description] AS [Description] FROM [Company CH$Brand Product Line] WHERE [Company CH$Brand Product Line].[Promotional Order Active] = :where1 ORDER BY [Description] ASC
Try disable quote identifiers in parameters of the PDO connection.
For Oracle it is looks like
use Laminas\Db\Adapter\Adapter;
$this->hostname = getenv('TESTS_LAMINAS_DB_ADAPTER_DRIVER_OCI8_HOSTNAME');
$this->database = getenv('TESTS_LAMINAS_DB_ADAPTER_DRIVER_OCI8_DATABASE');
$this->username = getenv('TESTS_LAMINAS_DB_ADAPTER_DRIVER_OCI8_USERNAME');
$this->password = getenv('TESTS_LAMINAS_DB_ADAPTER_DRIVER_OCI8_PASSWORD');
$this->dsn = sprintf('oci:dbname=//%s/%s',
$this->hostname,
$this->database
);
$driverOptions = [
'driver' => 'pdo_oci',
'dsn' => $this->dsn,
'username' => $this->username,
'password' => $this->password,
'platform_options' => [
'quote_identifiers' => false // <<< !!! HERE !!!
],
];
$adapter = new Adapter($driverOptions);
@ZVanoZ I already tried this. The problem is then that other things are not quoted that should be.
Identifier quoting issues are often related to #77 (original discussion at zendframework/zend-db#233) and maybe zendframework/zend-db#232. Maybe something in there could give a useful hint to fix in own fork fix.
quoteIdentifierChain might give better results, but those PRs need to be revisted for proper solution.
I have the same issue and also with brackets as table name (like Amount (LCY)
which will be quoted as [Amount] [(][LCY][)]
).
Is there any solution for brackets?
I had made an own fork and fixed the whitespace issue based on the closed issue 84.
But i can't find a good solution for brackets.
When this issue with whitespaces will be fixed? The solution was given 2 years ago.