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
ba61dd3d
Commit
ba61dd3d
authored
May 08, 2014
by
Steve Müller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #553 from deeky666/DBAL-843
[DBAL-843] Fix reverse engineering LOB type column types in MySQL
parents
5cbe3ce8
829eb1c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
4 deletions
+79
-4
MySqlSchemaManager.php
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
+19
-4
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+60
-0
No files found.
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
View file @
ba61dd3d
...
...
@@ -19,6 +19,7 @@
namespace
Doctrine\DBAL\Schema
;
use
Doctrine\DBAL\Platforms\MySqlPlatform
;
use
Doctrine\DBAL\Types\Type
;
/**
...
...
@@ -146,16 +147,30 @@ class MySqlSchemaManager extends AbstractSchemaManager
$length
=
null
;
}
break
;
case
'tinytext'
:
$length
=
MySqlPlatform
::
LENGTH_LIMIT_TINYTEXT
;
break
;
case
'text'
:
$length
=
MySqlPlatform
::
LENGTH_LIMIT_TEXT
;
break
;
case
'mediumtext'
:
$length
=
MySqlPlatform
::
LENGTH_LIMIT_MEDIUMTEXT
;
break
;
case
'tinyblob'
:
$length
=
MySqlPlatform
::
LENGTH_LIMIT_TINYBLOB
;
break
;
case
'blob'
:
$length
=
MySqlPlatform
::
LENGTH_LIMIT_BLOB
;
break
;
case
'mediumblob'
:
$length
=
MySqlPlatform
::
LENGTH_LIMIT_MEDIUMBLOB
;
break
;
case
'tinyint'
:
case
'smallint'
:
case
'mediumint'
:
case
'int'
:
case
'integer'
:
case
'bigint'
:
case
'tinyblob'
:
case
'mediumblob'
:
case
'longblob'
:
case
'blob'
:
case
'year'
:
$length
=
null
;
break
;
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
ba61dd3d
...
...
@@ -2,6 +2,7 @@
namespace
Doctrine\Tests\DBAL\Functional\Schema
;
use
Doctrine\DBAL\Platforms\MySqlPlatform
;
use
Doctrine\DBAL\Schema\Comparator
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\DBAL\Schema\Table
;
...
...
@@ -199,4 +200,63 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this
->
assertEquals
(
'latin1_swedish_ci'
,
$columns
[
'foo'
]
->
getPlatformOption
(
'collation'
));
$this
->
assertEquals
(
'utf8_general_ci'
,
$columns
[
'bar'
]
->
getPlatformOption
(
'collation'
));
}
/**
* @group DBAL-843
*/
public
function
testListLobTypeColumns
()
{
$tableName
=
'lob_type_columns'
;
$table
=
new
Table
(
$tableName
);
$table
->
addColumn
(
'col_tinytext'
,
'text'
,
array
(
'length'
=>
MySqlPlatform
::
LENGTH_LIMIT_TINYTEXT
));
$table
->
addColumn
(
'col_text'
,
'text'
,
array
(
'length'
=>
MySqlPlatform
::
LENGTH_LIMIT_TEXT
));
$table
->
addColumn
(
'col_mediumtext'
,
'text'
,
array
(
'length'
=>
MySqlPlatform
::
LENGTH_LIMIT_MEDIUMTEXT
));
$table
->
addColumn
(
'col_longtext'
,
'text'
);
$table
->
addColumn
(
'col_tinyblob'
,
'text'
,
array
(
'length'
=>
MySqlPlatform
::
LENGTH_LIMIT_TINYBLOB
));
$table
->
addColumn
(
'col_blob'
,
'blob'
,
array
(
'length'
=>
MySqlPlatform
::
LENGTH_LIMIT_BLOB
));
$table
->
addColumn
(
'col_mediumblob'
,
'blob'
,
array
(
'length'
=>
MySqlPlatform
::
LENGTH_LIMIT_MEDIUMBLOB
));
$table
->
addColumn
(
'col_longblob'
,
'blob'
);
$this
->
_sm
->
dropAndCreateTable
(
$table
);
$platform
=
$this
->
_sm
->
getDatabasePlatform
();
$offlineColumns
=
$table
->
getColumns
();
$onlineColumns
=
$this
->
_sm
->
listTableColumns
(
$tableName
);
$this
->
assertSame
(
$platform
->
getClobTypeDeclarationSQL
(
$offlineColumns
[
'col_tinytext'
]
->
toArray
()),
$platform
->
getClobTypeDeclarationSQL
(
$onlineColumns
[
'col_tinytext'
]
->
toArray
())
);
$this
->
assertSame
(
$platform
->
getClobTypeDeclarationSQL
(
$offlineColumns
[
'col_text'
]
->
toArray
()),
$platform
->
getClobTypeDeclarationSQL
(
$onlineColumns
[
'col_text'
]
->
toArray
())
);
$this
->
assertSame
(
$platform
->
getClobTypeDeclarationSQL
(
$offlineColumns
[
'col_mediumtext'
]
->
toArray
()),
$platform
->
getClobTypeDeclarationSQL
(
$onlineColumns
[
'col_mediumtext'
]
->
toArray
())
);
$this
->
assertSame
(
$platform
->
getClobTypeDeclarationSQL
(
$offlineColumns
[
'col_longtext'
]
->
toArray
()),
$platform
->
getClobTypeDeclarationSQL
(
$onlineColumns
[
'col_longtext'
]
->
toArray
())
);
$this
->
assertSame
(
$platform
->
getBlobTypeDeclarationSQL
(
$offlineColumns
[
'col_tinyblob'
]
->
toArray
()),
$platform
->
getBlobTypeDeclarationSQL
(
$onlineColumns
[
'col_tinyblob'
]
->
toArray
())
);
$this
->
assertSame
(
$platform
->
getBlobTypeDeclarationSQL
(
$offlineColumns
[
'col_blob'
]
->
toArray
()),
$platform
->
getBlobTypeDeclarationSQL
(
$onlineColumns
[
'col_blob'
]
->
toArray
())
);
$this
->
assertSame
(
$platform
->
getBlobTypeDeclarationSQL
(
$offlineColumns
[
'col_mediumblob'
]
->
toArray
()),
$platform
->
getBlobTypeDeclarationSQL
(
$onlineColumns
[
'col_mediumblob'
]
->
toArray
())
);
$this
->
assertSame
(
$platform
->
getBlobTypeDeclarationSQL
(
$offlineColumns
[
'col_longblob'
]
->
toArray
()),
$platform
->
getBlobTypeDeclarationSQL
(
$onlineColumns
[
'col_longblob'
]
->
toArray
())
);
}
}
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