Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
ff6cbdbc
Unverified
Commit
ff6cbdbc
authored
Nov 11, 2018
by
Sergei Morozov
Committed by
GitHub
Nov 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3330 from morozov/issues/3328
Fixed quoting of string literals containing backslash
parents
822d9702
aaf2b631
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
36 deletions
+46
-36
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+0
-11
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+0
-11
QuotingTest.php
...s/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php
+32
-0
AbstractPostgreSqlPlatformTestCase.php
...sts/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
+8
-8
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+6
-6
No files found.
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
ff6cbdbc
...
@@ -21,7 +21,6 @@ use function func_num_args;
...
@@ -21,7 +21,6 @@ use function func_num_args;
use
function
implode
;
use
function
implode
;
use
function
preg_match
;
use
function
preg_match
;
use
function
sprintf
;
use
function
sprintf
;
use
function
str_replace
;
use
function
strlen
;
use
function
strlen
;
use
function
strpos
;
use
function
strpos
;
use
function
strtoupper
;
use
function
strtoupper
;
...
@@ -1175,14 +1174,4 @@ SQL
...
@@ -1175,14 +1174,4 @@ SQL
{
{
return
'BLOB'
;
return
'BLOB'
;
}
}
/**
* {@inheritdoc}
*/
public
function
quoteStringLiteral
(
$str
)
{
$str
=
str_replace
(
'\\'
,
'\\\\'
,
$str
);
// Oracle requires backslashes to be escaped aswell.
return
parent
::
quoteStringLiteral
(
$str
);
}
}
}
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
ff6cbdbc
...
@@ -28,7 +28,6 @@ use function is_bool;
...
@@ -28,7 +28,6 @@ use function is_bool;
use
function
is_numeric
;
use
function
is_numeric
;
use
function
is_string
;
use
function
is_string
;
use
function
sprintf
;
use
function
sprintf
;
use
function
str_replace
;
use
function
strpos
;
use
function
strpos
;
use
function
strtolower
;
use
function
strtolower
;
use
function
trim
;
use
function
trim
;
...
@@ -1199,16 +1198,6 @@ SQL
...
@@ -1199,16 +1198,6 @@ SQL
return
'BYTEA'
;
return
'BYTEA'
;
}
}
/**
* {@inheritdoc}
*/
public
function
quoteStringLiteral
(
$str
)
{
$str
=
str_replace
(
'\\'
,
'\\\\'
,
$str
);
// PostgreSQL requires backslashes to be escaped aswell.
return
parent
::
quoteStringLiteral
(
$str
);
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
...
...
tests/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php
0 → 100644
View file @
ff6cbdbc
<?php
namespace
Doctrine\Tests\DBAL\Functional\Platform
;
use
Doctrine\Tests\DbalFunctionalTestCase
;
class
QuotingTest
extends
DbalFunctionalTestCase
{
/**
* @dataProvider stringLiteralProvider
*/
public
function
testQuoteStringLiteral
(
string
$string
)
:
void
{
$platform
=
$this
->
connection
->
getDatabasePlatform
();
$query
=
$platform
->
getDummySelectSQL
(
$platform
->
quoteStringLiteral
(
$string
)
);
self
::
assertSame
(
$string
,
$this
->
connection
->
fetchColumn
(
$query
));
}
/**
* @return mixed[][]
*/
public
static
function
stringLiteralProvider
()
:
iterable
{
return
[
'backslash'
=>
[
'\\'
],
'single-quote'
=>
[
"'"
],
];
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
View file @
ff6cbdbc
...
@@ -952,7 +952,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
...
@@ -952,7 +952,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
*/
public
function
testQuotesTableNameInListTableForeignKeysSQL
()
public
function
testQuotesTableNameInListTableForeignKeysSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListTableForeignKeysSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableForeignKeysSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
}
}
/**
/**
...
@@ -961,7 +961,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
...
@@ -961,7 +961,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
public
function
testQuotesSchemaNameInListTableForeignKeysSQL
()
public
function
testQuotesSchemaNameInListTableForeignKeysSQL
()
{
{
self
::
assertContains
(
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableForeignKeysSQL
(
"Foo'Bar
\\
.baz_table"
),
$this
->
platform
->
getListTableForeignKeysSQL
(
"Foo'Bar
\\
.baz_table"
),
''
,
''
,
true
true
...
@@ -973,7 +973,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
...
@@ -973,7 +973,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
*/
public
function
testQuotesTableNameInListTableConstraintsSQL
()
public
function
testQuotesTableNameInListTableConstraintsSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListTableConstraintsSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableConstraintsSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
}
}
/**
/**
...
@@ -981,7 +981,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
...
@@ -981,7 +981,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
*/
public
function
testQuotesTableNameInListTableIndexesSQL
()
public
function
testQuotesTableNameInListTableIndexesSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListTableIndexesSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableIndexesSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
}
}
/**
/**
...
@@ -990,7 +990,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
...
@@ -990,7 +990,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
public
function
testQuotesSchemaNameInListTableIndexesSQL
()
public
function
testQuotesSchemaNameInListTableIndexesSQL
()
{
{
self
::
assertContains
(
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableIndexesSQL
(
"Foo'Bar
\\
.baz_table"
),
$this
->
platform
->
getListTableIndexesSQL
(
"Foo'Bar
\\
.baz_table"
),
''
,
''
,
true
true
...
@@ -1002,7 +1002,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
...
@@ -1002,7 +1002,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
*/
public
function
testQuotesTableNameInListTableColumnsSQL
()
public
function
testQuotesTableNameInListTableColumnsSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListTableColumnsSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableColumnsSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
}
}
/**
/**
...
@@ -1011,7 +1011,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
...
@@ -1011,7 +1011,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
public
function
testQuotesSchemaNameInListTableColumnsSQL
()
public
function
testQuotesSchemaNameInListTableColumnsSQL
()
{
{
self
::
assertContains
(
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableColumnsSQL
(
"Foo'Bar
\\
.baz_table"
),
$this
->
platform
->
getListTableColumnsSQL
(
"Foo'Bar
\\
.baz_table"
),
''
,
''
,
true
true
...
@@ -1024,7 +1024,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
...
@@ -1024,7 +1024,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
public
function
testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL
()
public
function
testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL
()
{
{
self
::
assertContains
(
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getCloseActiveDatabaseConnectionsSQL
(
"Foo'Bar
\\
"
),
$this
->
platform
->
getCloseActiveDatabaseConnectionsSQL
(
"Foo'Bar
\\
"
),
''
,
''
,
true
true
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
ff6cbdbc
...
@@ -875,7 +875,7 @@ SQL
...
@@ -875,7 +875,7 @@ SQL
*/
*/
public
function
testQuotesDatabaseNameInListSequencesSQL
()
public
function
testQuotesDatabaseNameInListSequencesSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListSequencesSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListSequencesSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
}
}
/**
/**
...
@@ -883,7 +883,7 @@ SQL
...
@@ -883,7 +883,7 @@ SQL
*/
*/
public
function
testQuotesTableNameInListTableIndexesSQL
()
public
function
testQuotesTableNameInListTableIndexesSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListTableIndexesSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableIndexesSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
}
}
/**
/**
...
@@ -891,7 +891,7 @@ SQL
...
@@ -891,7 +891,7 @@ SQL
*/
*/
public
function
testQuotesTableNameInListTableForeignKeysSQL
()
public
function
testQuotesTableNameInListTableForeignKeysSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListTableForeignKeysSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableForeignKeysSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
}
}
/**
/**
...
@@ -899,7 +899,7 @@ SQL
...
@@ -899,7 +899,7 @@ SQL
*/
*/
public
function
testQuotesTableNameInListTableConstraintsSQL
()
public
function
testQuotesTableNameInListTableConstraintsSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListTableConstraintsSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableConstraintsSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
}
}
/**
/**
...
@@ -907,7 +907,7 @@ SQL
...
@@ -907,7 +907,7 @@ SQL
*/
*/
public
function
testQuotesTableNameInListTableColumnsSQL
()
public
function
testQuotesTableNameInListTableColumnsSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListTableColumnsSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableColumnsSQL
(
"Foo'Bar
\\
"
),
''
,
true
);
}
}
/**
/**
...
@@ -915,6 +915,6 @@ SQL
...
@@ -915,6 +915,6 @@ SQL
*/
*/
public
function
testQuotesDatabaseNameInListTableColumnsSQL
()
public
function
testQuotesDatabaseNameInListTableColumnsSQL
()
{
{
self
::
assertContains
(
"'Foo''Bar
\\
\\
'"
,
$this
->
platform
->
getListTableColumnsSQL
(
'foo_table'
,
"Foo'Bar
\\
"
),
''
,
true
);
self
::
assertContains
(
"'Foo''Bar
\\
'"
,
$this
->
platform
->
getListTableColumnsSQL
(
'foo_table'
,
"Foo'Bar
\\
"
),
''
,
true
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment