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
345b650b
Unverified
Commit
345b650b
authored
Oct 30, 2017
by
belgattitude
Committed by
Luís Cobucci
Nov 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes mariadb supports for TEXT/BLOB default values
parent
9ca9589d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
95 deletions
+1
-95
MariaDb1027Platform.php
lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php
+0
-11
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+1
-1
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+0
-34
MariaDb1027PlatformTest.php
...Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php
+0
-49
No files found.
lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php
View file @
345b650b
...
@@ -66,15 +66,4 @@ final class MariaDb1027Platform extends MySqlPlatform
...
@@ -66,15 +66,4 @@ final class MariaDb1027Platform extends MySqlPlatform
$this
->
doctrineTypeMapping
[
'json'
]
=
Type
::
JSON
;
$this
->
doctrineTypeMapping
[
'json'
]
=
Type
::
JSON
;
}
}
/**
* @inheritdoc
*
* Since MariaDB 10.2.1 blob and text columns can have a default value.
* @link https://mariadb.com/kb/en/library/blob-and-text-data-types/
*/
protected
function
isDefaultValueSupportedForType
(
Type
$field
)
:
bool
{
return
true
;
}
}
}
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
345b650b
...
@@ -582,7 +582,7 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -582,7 +582,7 @@ class MySqlPlatform extends AbstractPlatform
// Don't propagate default value changes for unsupported column types.
// Don't propagate default value changes for unsupported column types.
if
(
$columnDiff
->
hasChanged
(
'default'
)
&&
if
(
$columnDiff
->
hasChanged
(
'default'
)
&&
count
(
$columnDiff
->
changedProperties
)
===
1
&&
count
(
$columnDiff
->
changedProperties
)
===
1
&&
!
$this
->
isDefaultValueSupportedForType
(
$columnArray
[
'type'
]
)
(
$columnArray
[
'type'
]
instanceof
TextType
||
$columnArray
[
'type'
]
instanceof
BlobType
)
)
{
)
{
continue
;
continue
;
}
}
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
345b650b
...
@@ -446,38 +446,4 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
...
@@ -446,38 +446,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."
);
}
}
/**
* Since MariaDB 10.2.1, Blob and text columns can have a default value
*
* @link https://mariadb.com/kb/en/library/blob-and-text-data-types
*/
public
function
testDoesPropagateDefaultValuesForBlobTextAndJson
()
:
void
{
if
(
!
$this
->
_sm
->
getDatabasePlatform
()
instanceof
MariaDb1027Platform
)
{
$this
->
markTestSkipped
(
'Only relevant for MariaDb102Platform.'
);
}
$table
=
new
Table
(
"text_blob_default_value"
);
$json
=
json_encode
([
'prop1'
=>
"Hello"
,
'prop2'
=>
10
]);
$table
->
addColumn
(
'def_text'
,
'text'
,
[
'default'
=>
"Hello"
]);
$table
->
addColumn
(
'def_text_null'
,
'text'
,
[
'notnull'
=>
false
,
'default'
=>
'def'
]);
$table
->
addColumn
(
'def_blob'
,
'blob'
,
[
'default'
=>
'World'
]);
$table
->
addColumn
(
'def_json'
,
'json'
,
[
'default'
=>
$json
]);
$this
->
_sm
->
dropAndCreateTable
(
$table
);
$onlineTable
=
$this
->
_sm
->
listTableDetails
(
"text_blob_default_value"
);
self
::
assertSame
(
"Hello"
,
$onlineTable
->
getColumn
(
'def_text'
)
->
getDefault
());
self
::
assertSame
(
'def'
,
$onlineTable
->
getColumn
(
'def_text_null'
)
->
getDefault
());
self
::
assertSame
(
'World'
,
$onlineTable
->
getColumn
(
'def_blob'
)
->
getDefault
());
self
::
assertSame
(
$json
,
$onlineTable
->
getColumn
(
'def_json'
)
->
getDefault
());
$comparator
=
new
Comparator
();
self
::
assertFalse
(
$comparator
->
diffTable
(
$table
,
$onlineTable
));
}
}
}
tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php
View file @
345b650b
...
@@ -47,53 +47,4 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase
...
@@ -47,53 +47,4 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase
{
{
$this
->
markTestSkipped
(
'MariaDB102Platform support propagation of default values for BLOB and TEXT columns'
);
$this
->
markTestSkipped
(
'MariaDB102Platform support propagation of default values for BLOB and TEXT columns'
);
}
}
/**
* Since MariaDB 10.2, Text and Blob can have a default value.
*/
public
function
testPropagateDefaultValuesForTextAndBlobColumnTypes
()
:
void
{
$table
=
new
Table
(
"text_blob_default_value"
);
$table
->
addColumn
(
'def_text'
,
Type
::
TEXT
,
[
'default'
=>
"hello"
]);
$table
->
addColumn
(
'def_blob'
,
Type
::
BLOB
,
[
'default'
=>
'world'
]);
self
::
assertSame
(
[
"CREATE TABLE text_blob_default_value (def_text LONGTEXT DEFAULT 'hello' NOT NULL, def_blob LONGBLOB DEFAULT 'world' NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"
],
$this
->
_platform
->
getCreateTableSQL
(
$table
)
);
$diffTable
=
clone
$table
;
$diffTable
->
changeColumn
(
'def_text'
,
[
'default'
=>
"hello"
]);
$diffTable
->
changeColumn
(
'def_blob'
,
[
'default'
=>
'world'
]);
$comparator
=
new
Comparator
();
self
::
assertFalse
(
$comparator
->
diffTable
(
$table
,
$diffTable
));
}
public
function
testPropagateDefaultValuesForJsonColumnType
()
:
void
{
$table
=
new
Table
(
"text_json_default_value"
);
$json
=
json_encode
([
'prop1'
=>
"Hello"
,
'prop2'
=>
10
]);
$table
->
addColumn
(
'def_json'
,
Type
::
TEXT
,
[
'default'
=>
$json
]);
$jsonType
=
$this
->
createPlatform
()
->
getJsonTypeDeclarationSQL
(
$table
->
getColumn
(
'def_json'
)
->
toArray
());
self
::
assertSame
(
[
"CREATE TABLE text_json_default_value (def_json
$jsonType
DEFAULT '
{
\"prop1\":\"Hello\",\"prop2\":10
}
' NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"
],
$this
->
_platform
->
getCreateTableSQL
(
$table
)
);
$diffTable
=
clone
$table
;
$diffTable
->
changeColumn
(
'def_json'
,
[
'default'
=>
$json
]);
$comparator
=
new
Comparator
();
self
::
assertFalse
(
$comparator
->
diffTable
(
$table
,
$diffTable
));
}
}
}
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