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
c98c5482
Unverified
Commit
c98c5482
authored
Sep 01, 2019
by
Sergei Morozov
Committed by
GitHub
Sep 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3668 from staudenmeir/mysql-collation
Quote collation on MySQL
parents
d9b377cd
733b64bc
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
20 deletions
+31
-20
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+9
-1
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+3
-0
AbstractMySQLPlatformTestCase.php
...ne/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+16
-16
MySqlInheritCharsetTest.php
tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php
+3
-3
No files found.
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
c98c5482
...
...
@@ -503,7 +503,7 @@ SQL
$options
[
'collate'
]
=
$options
[
'charset'
]
.
'_unicode_ci'
;
}
$tableOptions
[]
=
sprintf
(
'COLLATE %s'
,
$options
[
'collate'
]);
$tableOptions
[]
=
$this
->
getColumnCollationDeclarationSQL
(
$options
[
'collate'
]);
// Engine
if
(
!
isset
(
$options
[
'engine'
]))
{
...
...
@@ -965,6 +965,14 @@ SQL
return
'CHARACTER SET '
.
$charset
;
}
/**
* {@inheritDoc}
*/
public
function
getColumnCollationDeclarationSQL
(
$collation
)
{
return
'COLLATE '
.
$this
->
quoteSingleIdentifier
(
$collation
);
}
/**
* {@inheritDoc}
*/
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
c98c5482
...
...
@@ -8,6 +8,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform;
use
Doctrine\DBAL\Schema\Comparator
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Types\BlobType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Types\Types
;
use
Doctrine\Tests\Types\MySqlPointType
;
...
...
@@ -275,6 +276,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$table
->
addColumn
(
'text'
,
'text'
);
$table
->
addColumn
(
'foo'
,
'text'
)
->
setPlatformOption
(
'collation'
,
'latin1_swedish_ci'
);
$table
->
addColumn
(
'bar'
,
'text'
)
->
setPlatformOption
(
'collation'
,
'utf8_general_ci'
);
$table
->
addColumn
(
'baz'
,
'text'
)
->
setPlatformOption
(
'collation'
,
'binary'
);
$this
->
schemaManager
->
dropAndCreateTable
(
$table
);
$columns
=
$this
->
schemaManager
->
listTableColumns
(
'test_collation'
);
...
...
@@ -283,6 +285,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self
::
assertEquals
(
'latin1_swedish_ci'
,
$columns
[
'text'
]
->
getPlatformOption
(
'collation'
));
self
::
assertEquals
(
'latin1_swedish_ci'
,
$columns
[
'foo'
]
->
getPlatformOption
(
'collation'
));
self
::
assertEquals
(
'utf8_general_ci'
,
$columns
[
'bar'
]
->
getPlatformOption
(
'collation'
));
self
::
assertInstanceOf
(
BlobType
::
class
,
$columns
[
'baz'
]
->
getType
());
}
/**
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
View file @
c98c5482
This diff is collapsed.
Click to expand it.
tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php
View file @
c98c5482
...
...
@@ -45,7 +45,7 @@ class MySqlInheritCharsetTest extends TestCase
$table
=
new
Table
(
'foobar'
,
[
new
Column
(
'aa'
,
Type
::
getType
(
'integer'
))]);
self
::
assertSame
(
$platform
->
getCreateTableSQL
(
$table
),
[
'CREATE TABLE foobar (aa INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE
utf8_unicode_ci
ENGINE = InnoDB'
]
[
'CREATE TABLE foobar (aa INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE
`utf8_unicode_ci`
ENGINE = InnoDB'
]
);
// explicit utf8
...
...
@@ -53,7 +53,7 @@ class MySqlInheritCharsetTest extends TestCase
$table
->
addOption
(
'charset'
,
'utf8'
);
self
::
assertSame
(
$platform
->
getCreateTableSQL
(
$table
),
[
'CREATE TABLE foobar (aa INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE
utf8_unicode_ci
ENGINE = InnoDB'
]
[
'CREATE TABLE foobar (aa INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE
`utf8_unicode_ci`
ENGINE = InnoDB'
]
);
// explicit utf8mb4
...
...
@@ -61,7 +61,7 @@ class MySqlInheritCharsetTest extends TestCase
$table
->
addOption
(
'charset'
,
'utf8mb4'
);
self
::
assertSame
(
$platform
->
getCreateTableSQL
(
$table
),
[
'CREATE TABLE foobar (aa INT NOT NULL) DEFAULT CHARACTER SET utf8mb4 COLLATE
utf8mb4_unicode_ci
ENGINE = InnoDB'
]
[
'CREATE TABLE foobar (aa INT NOT NULL) DEFAULT CHARACTER SET utf8mb4 COLLATE
`utf8mb4_unicode_ci`
ENGINE = InnoDB'
]
);
}
...
...
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