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
6e920f38
Unverified
Commit
6e920f38
authored
Dec 08, 2017
by
Adrien Crivelli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test same escaped sequences across all platforms
parent
a50a029f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
36 deletions
+26
-36
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+0
-1
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+0
-26
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+26
-9
No files found.
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
6e920f38
...
@@ -483,7 +483,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -483,7 +483,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
return
$default
;
return
$default
;
}
}
$default
=
str_replace
(
"
\\\\
"
,
"
\\
"
,
$default
);
$default
=
str_replace
(
"''"
,
"'"
,
$default
);
$default
=
str_replace
(
"''"
,
"'"
,
$default
);
return
$default
;
return
$default
;
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
6e920f38
...
@@ -442,30 +442,4 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
...
@@ -442,30 +442,4 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$diff
=
$comparator
->
diffTable
(
$table
,
$onlineTable
);
$diff
=
$comparator
->
diffTable
(
$table
,
$onlineTable
);
self
::
assertFalse
(
$diff
,
"Tables should be identical with column defauts time and date."
);
self
::
assertFalse
(
$diff
,
"Tables should be identical with column defauts time and date."
);
}
}
/**
* Returns literals that are platform specific escaped.
*
* @see https://dev.mysql.com/doc/refman/5.7/en/string-literals.html
*
* @return array
*/
protected
function
getEscapedLiterals
()
:
array
{
return
[
"
\\
0"
,
// An ASCII NUL (X'00') character
"
\\
'"
,
// Single quote
"''"
,
// Single quote
'\\"'
,
// Double quote
'""'
,
// Double quote
'\\b'
,
// A backspace character
'\\n'
,
// A new-line character
'\\r'
,
// A carriage return character
'\\t'
,
// A tab character
'\\Z'
,
// ASCII 26 (Control+Z)
'\\\\'
,
// A backslash (\) character
'\\%'
,
// A percent (%) character
'\\_'
,
// An underscore (_) character
];
}
}
}
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
6e920f38
...
@@ -1399,24 +1399,41 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
...
@@ -1399,24 +1399,41 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
}
}
/**
/**
* Returns literals that are platform specific escaped.
* Returns potential escaped literals from all platforms combined.
*
* @see https://dev.mysql.com/doc/refman/5.7/en/string-literals.html
* @see http://www.sqlite.org/lang_expr.html
* @see https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE
*
*
* @return array
* @return array
*/
*/
p
rotected
function
getEscapedLiterals
()
:
array
p
ublic
function
getEscapedLiterals
()
:
array
{
{
return
[
return
[
"
\\
'"
,
// A single quote
'An ASCII NUL (X\'00\')'
=>
[
"
\\
0"
],
'\\"'
,
// A double quote
'Single quote, C-style'
=>
[
"
\\
'"
],
'\\n'
,
// A new-line character
'Single quote, doubled-style'
=>
[
"''"
],
'\\r'
,
// A carriage return character
'Double quote, C-style'
=>
[
'\\"'
],
'Double quote, double-style'
=>
[
'""'
],
'Backspace'
=>
[
'\\b'
],
'New-line'
=>
[
'\\n'
],
'Carriage return'
=>
[
'\\r'
],
'Tab'
=>
[
'\\t'
],
'ASCII 26 (Control+Z)'
=>
[
'\\Z'
],
'Backslash (\)'
=>
[
'\\\\'
],
'Percent (%)'
=>
[
'\\%'
],
'Underscore (_)'
=>
[
'\\_'
],
];
];
}
}
public
function
testEscapedDefaultValueMustBePreserved
()
:
void
/**
* @dataProvider getEscapedLiterals
*
* @param string $value
*/
public
function
testEscapedDefaultValueMustBePreserved
(
string
$value
)
:
void
{
{
$value
=
implode
(
'+'
,
$this
->
getEscapedLiterals
());
$value
=
'foo'
.
$value
.
'bar'
;
$table
=
new
Table
(
'string_escaped_default_value'
);
$table
=
new
Table
(
'string_escaped_default_value'
);
$table
->
addColumn
(
'def_string'
,
'string'
,
array
(
'default'
=>
$value
));
$table
->
addColumn
(
'def_string'
,
'string'
,
array
(
'default'
=>
$value
));
$table
->
addColumn
(
'def_foo'
,
'string'
);
$table
->
addColumn
(
'def_foo'
,
'string'
);
...
...
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