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

SQLServer platform quoteIdentifier wrong escaping #4643

Closed
zajca opened this issue May 11, 2021 · 2 comments · Fixed by #4648
Closed

SQLServer platform quoteIdentifier wrong escaping #4643

zajca opened this issue May 11, 2021 · 2 comments · Fixed by #4648

Comments

@zajca
Copy link

zajca commented May 11, 2021

Bug Report

Q A
BC Break no
Version all

Summary

It looks like that escaping identifier for sql platform is broken since day one.

Current behaviour

This is in tests:

self::assertEquals('[fo][o]', $this->platform->quoteSingleIdentifier('fo]o'));

But if I try for example create table

CREATE TABLE [test_escaping].[fo][o] ([col1] INT);
-- Failed to execute query. Error: Parse error at line: 1, column: 34: Incorrect syntax near '[o]'.

Expected behaviour

Expected output should be [fo]]o]

CREATE TABLE [test_escaping].[fo]]o] ([col1] INT);
-- Query succeeded: Affected rows: 0

So the function should be:

    public function quoteSingleIdentifier($str)
    {
        return '[' . str_replace(']', ']]', $str) . ']';
    }

Output is than same as from

SELECT QUOTENAME('fo]o');
-- [fo]]o]

https://docs.microsoft.com/en-us/sql/t-sql/functions/quotename-transact-sql?view=sql-server-ver15

@morozov
Copy link
Member

morozov commented May 15, 2021

Closed via #4648.

@morozov morozov closed this as completed May 15, 2021
derrabus added a commit to derrabus/dbal that referenced this issue Jun 5, 2021
* 2.13.x:
  Bump doctrine/coding-standard
  [doctrineGH-4643] Fix SQLServerPlatform::quoteIdentifier()
  [doctrineGH-4645] Use error suppression instead of an error handler in MySQLi Connection
  Rewrote `DriverManagerTest` replica/shards test scenarios to verify whole data structure equality
  Add type-inference tests to github actions, so that we test also that types match up
  Add warnings in docblocks
  Rework the caching documentation
  Fix doctrine#4637 by duplicating the type definition for `DriverManager::getConnection($args)` params
derrabus added a commit to derrabus/dbal that referenced this issue Jun 5, 2021
* 2.13.x:
  Bump doctrine/coding-standard
  [doctrineGH-4643] Fix SQLServerPlatform::quoteIdentifier()
  [doctrineGH-4645] Use error suppression instead of an error handler in MySQLi Connection
  Rewrote `DriverManagerTest` replica/shards test scenarios to verify whole data structure equality
  Add type-inference tests to github actions, so that we test also that types match up
  Add warnings in docblocks
  Rework the caching documentation
  Fix doctrine#4637 by duplicating the type definition for `DriverManager::getConnection($args)` params
derrabus added a commit to derrabus/dbal that referenced this issue Jun 5, 2021
* 2.13.x:
  Bump doctrine/coding-standard
  [doctrineGH-4643] Fix SQLServerPlatform::quoteIdentifier()
  [doctrineGH-4645] Use error suppression instead of an error handler in MySQLi Connection
  Rewrote `DriverManagerTest` replica/shards test scenarios to verify whole data structure equality
  Add type-inference tests to github actions, so that we test also that types match up
  Add warnings in docblocks
  Rework the caching documentation
  Fix doctrine#4637 by duplicating the type definition for `DriverManager::getConnection($args)` params
derrabus added a commit to derrabus/dbal that referenced this issue Jun 5, 2021
* 2.13.x:
  Bump doctrine/coding-standard
  [doctrineGH-4643] Fix SQLServerPlatform::quoteIdentifier()
  [doctrineGH-4645] Use error suppression instead of an error handler in MySQLi Connection
  Rewrote `DriverManagerTest` replica/shards test scenarios to verify whole data structure equality
  Add type-inference tests to github actions, so that we test also that types match up
  Add warnings in docblocks
  Rework the caching documentation
  Fix doctrine#4637 by duplicating the type definition for `DriverManager::getConnection($args)` params
derrabus added a commit to derrabus/dbal that referenced this issue Jun 6, 2021
* 2.13.x:
  Bump doctrine/coding-standard
  [doctrineGH-4643] Fix SQLServerPlatform::quoteIdentifier()
  [doctrineGH-4645] Use error suppression instead of an error handler in MySQLi Connection
  Rewrote `DriverManagerTest` replica/shards test scenarios to verify whole data structure equality
  Add type-inference tests to github actions, so that we test also that types match up
  Add warnings in docblocks
  Rework the caching documentation
  Fix doctrine#4637 by duplicating the type definition for `DriverManager::getConnection($args)` params
derrabus added a commit to derrabus/dbal that referenced this issue Jun 7, 2021
* 2.13.x:
  Bump doctrine/coding-standard
  [doctrineGH-4643] Fix SQLServerPlatform::quoteIdentifier()
  [doctrineGH-4645] Use error suppression instead of an error handler in MySQLi Connection
  Rewrote `DriverManagerTest` replica/shards test scenarios to verify whole data structure equality
  Add type-inference tests to github actions, so that we test also that types match up
  Add warnings in docblocks
  Rework the caching documentation
  Fix doctrine#4637 by duplicating the type definition for `DriverManager::getConnection($args)` params

Signed-off-by: Alexander M. Turek <me@derrabus.de>
derrabus added a commit to derrabus/dbal that referenced this issue Jun 7, 2021
* 2.13.x:
  Bump doctrine/coding-standard
  [doctrineGH-4643] Fix SQLServerPlatform::quoteIdentifier()
  [doctrineGH-4645] Use error suppression instead of an error handler in MySQLi Connection
  Rewrote `DriverManagerTest` replica/shards test scenarios to verify whole data structure equality
  Add type-inference tests to github actions, so that we test also that types match up
  Add warnings in docblocks
  Rework the caching documentation
  Fix doctrine#4637 by duplicating the type definition for `DriverManager::getConnection($args)` params

Signed-off-by: Alexander M. Turek <me@derrabus.de>
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants