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
a64d7481
Unverified
Commit
a64d7481
authored
Jun 18, 2018
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecated usage of binary fields whose length exceeds the platform maximum
Closes #3187.
parent
89a52c28
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
14 deletions
+79
-14
UPGRADE.md
UPGRADE.md
+5
-0
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+13
-1
AbstractMySQLPlatformTestCase.php
...ne/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+17
-6
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+5
-0
AbstractSQLServerPlatformTestCase.php
...ests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
+10
-2
DB2PlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
+9
-1
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+10
-2
SQLAnywherePlatformTest.php
...Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+10
-2
No files found.
UPGRADE.md
View file @
a64d7481
# Upgrade to 2.8
## Deprecated usage of binary fields whose length exceeds the platform maximum
-
The usage of binary fields whose length exceeds the maximum field size on a given platform is deprecated.
Use binary fields of a size which fits all target platforms, or use blob explicitly instead.
## Removed dependency on doctrine/common
The dependency on doctrine/common package has been removed.
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
a64d7481
...
...
@@ -42,6 +42,7 @@ use Doctrine\DBAL\Schema\TableDiff;
use
Doctrine\DBAL\TransactionIsolationLevel
;
use
Doctrine\DBAL\Types
;
use
Doctrine\DBAL\Types\Type
;
use
const
E_USER_DEPRECATED
;
use
function
addcslashes
;
use
function
array_map
;
use
function
array_merge
;
...
...
@@ -68,6 +69,7 @@ use function strlen;
use
function
strpos
;
use
function
strtolower
;
use
function
strtoupper
;
use
function
trigger_error
;
/**
* Base class for all DatabasePlatforms. The DatabasePlatforms are the central
...
...
@@ -325,7 +327,17 @@ abstract class AbstractPlatform
$fixed
=
$field
[
'fixed'
]
??
false
;
if
(
$field
[
'length'
]
>
$this
->
getBinaryMaxLength
())
{
$maxLength
=
$this
->
getBinaryMaxLength
();
if
(
$field
[
'length'
]
>
$maxLength
)
{
if
(
$maxLength
>
0
)
{
@
trigger_error
(
sprintf
(
'Binary field length %d is greater than supported by the platform (%d)'
,
$field
[
'length'
],
$maxLength
),
E_USER_DEPRECATED
);
}
return
$this
->
getBlobTypeDeclarationSQL
(
$field
);
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
View file @
a64d7481
...
...
@@ -519,16 +519,27 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
self
::
assertSame
(
'VARBINARY(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
()));
self
::
assertSame
(
'VARBINARY(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
0
)));
self
::
assertSame
(
'VARBINARY(65535)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
65535
)));
self
::
assertSame
(
'MEDIUMBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
65536
)));
self
::
assertSame
(
'MEDIUMBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
16777215
)));
self
::
assertSame
(
'LONGBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
16777216
)));
self
::
assertSame
(
'BINARY(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
)));
self
::
assertSame
(
'BINARY(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
0
)));
self
::
assertSame
(
'BINARY(65535)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
65535
)));
self
::
assertSame
(
'MEDIUMBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
65536
)));
self
::
assertSame
(
'MEDIUMBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
16777215
)));
self
::
assertSame
(
'LONGBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
16777216
)));
}
/**
* @group legacy
* @expectedDeprecation Binary field length 65536 is greater than supported by the platform (65535)
* @expectedDeprecation Binary field length 16777215 is greater than supported by the platform (65535)
* @expectedDeprecation Binary field length 16777216 is greater than supported by the platform (65535)
*/
public
function
testReturnsBinaryTypeLongerThanMaxDeclarationSQL
()
{
self
::
assertSame
(
'MEDIUMBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
65536
]));
self
::
assertSame
(
'MEDIUMBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
16777215
]));
self
::
assertSame
(
'LONGBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
16777216
]));
self
::
assertSame
(
'MEDIUMBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'fixed'
=>
true
,
'length'
=>
65536
]));
self
::
assertSame
(
'MEDIUMBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'fixed'
=>
true
,
'length'
=>
16777215
]));
self
::
assertSame
(
'LONGBLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'fixed'
=>
true
,
'length'
=>
16777216
]));
}
public
function
testDoesNotPropagateForeignKeyCreationForNonSupportingEngines
()
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
a64d7481
...
...
@@ -830,6 +830,11 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
());
}
public
function
testReturnsBinaryTypeLongerThanMaxDeclarationSQL
()
{
$this
->
markTestSkipped
(
'Not applicable to the platform'
);
}
/**
* @group DBAL-553
*/
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
View file @
a64d7481
...
...
@@ -981,12 +981,20 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
self
::
assertSame
(
'VARBINARY(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
()));
self
::
assertSame
(
'VARBINARY(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
0
)));
self
::
assertSame
(
'VARBINARY(8000)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
8000
)));
self
::
assertSame
(
'VARBINARY(MAX)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
8001
)));
self
::
assertSame
(
'BINARY(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
)));
self
::
assertSame
(
'BINARY(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
0
)));
self
::
assertSame
(
'BINARY(8000)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
8000
)));
self
::
assertSame
(
'VARBINARY(MAX)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
8001
)));
}
/**
* @group legacy
* @expectedDeprecation Binary field length 8001 is greater than supported by the platform (8000)
*/
public
function
testReturnsBinaryTypeLongerThanMaxDeclarationSQL
()
{
self
::
assertSame
(
'VARBINARY(MAX)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
8001
]));
self
::
assertSame
(
'VARBINARY(MAX)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'fixed'
=>
true
,
'length'
=>
8001
]));
}
/**
...
...
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
View file @
a64d7481
...
...
@@ -422,10 +422,18 @@ class DB2PlatformTest extends AbstractPlatformTestCase
self
::
assertSame
(
'VARCHAR(1) FOR BIT DATA'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([]));
self
::
assertSame
(
'VARCHAR(255) FOR BIT DATA'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
0
]));
self
::
assertSame
(
'VARCHAR(32704) FOR BIT DATA'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
32704
]));
self
::
assertSame
(
'BLOB(1M)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
32705
]));
self
::
assertSame
(
'CHAR(1) FOR BIT DATA'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'fixed'
=>
true
]));
self
::
assertSame
(
'CHAR(254) FOR BIT DATA'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'fixed'
=>
true
,
'length'
=>
0
]));
}
/**
* @group legacy
* @expectedDeprecation Binary field length 32705 is greater than supported by the platform (32704)
*/
public
function
testReturnsBinaryTypeLongerThanMaxDeclarationSQL
()
{
self
::
assertSame
(
'BLOB(1M)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
32705
]));
self
::
assertSame
(
'BLOB(1M)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'fixed'
=>
true
,
'length'
=>
32705
]));
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
a64d7481
...
...
@@ -446,12 +446,20 @@ class OraclePlatformTest extends AbstractPlatformTestCase
self
::
assertSame
(
'RAW(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
()));
self
::
assertSame
(
'RAW(2000)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
0
)));
self
::
assertSame
(
'RAW(2000)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
2000
)));
self
::
assertSame
(
'BLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
2001
)));
self
::
assertSame
(
'RAW(255)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
)));
self
::
assertSame
(
'RAW(2000)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
0
)));
self
::
assertSame
(
'RAW(2000)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
2000
)));
self
::
assertSame
(
'BLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
2001
)));
}
/**
* @group legacy
* @expectedDeprecation Binary field length 2001 is greater than supported by the platform (2000)
*/
public
function
testReturnsBinaryTypeLongerThanMaxDeclarationSQL
()
{
self
::
assertSame
(
'BLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
2001
]));
self
::
assertSame
(
'BLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'fixed'
=>
true
,
'length'
=>
2001
]));
}
public
function
testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType
()
...
...
tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
View file @
a64d7481
...
...
@@ -791,12 +791,20 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
self
::
assertSame
(
'VARBINARY(1)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
()));
self
::
assertSame
(
'VARBINARY(1)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
0
)));
self
::
assertSame
(
'VARBINARY(32767)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
32767
)));
self
::
assertSame
(
'LONG BINARY'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'length'
=>
32768
)));
self
::
assertSame
(
'BINARY(1)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
)));
self
::
assertSame
(
'BINARY(1)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
0
)));
self
::
assertSame
(
'BINARY(32767)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
32767
)));
self
::
assertSame
(
'LONG BINARY'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
32768
)));
}
/**
* @group legacy
* @expectedDeprecation Binary field length 32768 is greater than supported by the platform (32767)
*/
public
function
testReturnsBinaryTypeLongerThanMaxDeclarationSQL
()
{
self
::
assertSame
(
'LONG BINARY'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'length'
=>
32768
]));
self
::
assertSame
(
'LONG BINARY'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
([
'fixed'
=>
true
,
'length'
=>
32768
]));
}
/**
...
...
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