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
a4158b5c
Unverified
Commit
a4158b5c
authored
May 23, 2019
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3518 from Majkl578/drop-deprecated
Remove @deprecated stuff
parents
ff1bc0d7
b578a102
Changes
24
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
125 additions
and
783 deletions
+125
-783
UPGRADE.md
UPGRADE.md
+15
-0
Configuration.php
lib/Doctrine/DBAL/Configuration.php
+0
-12
Connection.php
lib/Doctrine/DBAL/Connection.php
+0
-28
MysqlSessionInit.php
lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php
+0
-60
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+0
-70
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+0
-16
SQLParserUtils.php
lib/Doctrine/DBAL/SQLParserUtils.php
+4
-23
AbstractSchemaManager.php
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+0
-10
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+0
-23
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+1
-1
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+4
-62
JsonArrayType.php
lib/Doctrine/DBAL/Types/JsonArrayType.php
+0
-48
Type.php
lib/Doctrine/DBAL/Types/Type.php
+0
-4
MysqlSessionInitTest.php
tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php
+0
-33
PostgreSqlSchemaManagerTest.php
...ts/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
+12
-21
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+0
-123
TypeConversionTest.php
tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
+2
-2
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+1
-1
AbstractPostgreSqlPlatformTestCase.php
...sts/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
+1
-1
SQLParserUtilsTest.php
tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
+78
-52
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+2
-2
DB2SchemaManagerTest.php
tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
+4
-104
MySQLSchemaTest.php
.../Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php
+1
-1
JsonArrayTest.php
tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
+0
-86
No files found.
UPGRADE.md
View file @
a4158b5c
# Upgrade to 3.0
## BC BREAK Removed previously deprecated features
*
Removed
`json_array`
type and all associated hacks.
*
Removed
`Connection::TRANSACTION_*`
constants.
*
Removed
`AbstractPlatform::DATE_INTERVAL_UNIT_*`
and
`AbstractPlatform::TRIM_*`
constants.
*
Removed
`MysqlSessionInit`
listener.
*
Removed
`MysqlPlatform::getCollationFieldDeclaration()`
.
*
Removed
`AbstractPlatform::getIdentityColumnNullInsertSQL()`
.
*
Removed
`Table::addUnnamedForeignKeyConstraint()`
and
`Table::addNamedForeignKeyConstraint()`
.
*
Removed
`Table::renameColumn()`
.
*
Removed
`SQLParserUtils::getPlaceholderPositions()`
.
*
Removed
`AbstractSchemaManager::getFilterSchemaAssetsExpression()`
,
`Configuration::getFilterSchemaAssetsExpression()`
and
`Configuration::getFilterSchemaAssetsExpression()`
.
*
`SQLParserUtils::*_TOKEN`
constants made private.
## BC BREAK `Connection::ping()` returns `void`.
`Connection::ping()`
and
`PingableConnection::ping()`
no longer return a boolean value. They will throw an exception in case of failure.
...
...
lib/Doctrine/DBAL/Configuration.php
View file @
a4158b5c
...
...
@@ -85,18 +85,6 @@ class Configuration
}
}
/**
* Returns filter schema assets expression.
*
* @deprecated Use Configuration::getSchemaAssetsFilter() instead
*
* @return string|null
*/
public
function
getFilterSchemaAssetsExpression
()
{
return
$this
->
_attributes
[
'filterSchemaAssetsExpression'
]
??
null
;
}
/**
* @param string $filterExpression
*/
...
...
lib/Doctrine/DBAL/Connection.php
View file @
a4158b5c
...
...
@@ -45,34 +45,6 @@ use function key;
*/
class
Connection
implements
DriverConnection
{
/**
* Constant for transaction isolation level READ UNCOMMITTED.
*
* @deprecated Use TransactionIsolationLevel::READ_UNCOMMITTED.
*/
public
const
TRANSACTION_READ_UNCOMMITTED
=
TransactionIsolationLevel
::
READ_UNCOMMITTED
;
/**
* Constant for transaction isolation level READ COMMITTED.
*
* @deprecated Use TransactionIsolationLevel::READ_COMMITTED.
*/
public
const
TRANSACTION_READ_COMMITTED
=
TransactionIsolationLevel
::
READ_COMMITTED
;
/**
* Constant for transaction isolation level REPEATABLE READ.
*
* @deprecated Use TransactionIsolationLevel::REPEATABLE_READ.
*/
public
const
TRANSACTION_REPEATABLE_READ
=
TransactionIsolationLevel
::
REPEATABLE_READ
;
/**
* Constant for transaction isolation level SERIALIZABLE.
*
* @deprecated Use TransactionIsolationLevel::SERIALIZABLE.
*/
public
const
TRANSACTION_SERIALIZABLE
=
TransactionIsolationLevel
::
SERIALIZABLE
;
/**
* Represents an array of ints to be expanded by Doctrine SQL parsing.
*/
...
...
lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php
deleted
100644 → 0
View file @
ff1bc0d7
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\DBAL\Event\Listeners
;
use
Doctrine\Common\EventSubscriber
;
use
Doctrine\DBAL\Event\ConnectionEventArgs
;
use
Doctrine\DBAL\Events
;
/**
* MySQL Session Init Event Subscriber which allows to set the Client Encoding of the Connection.
*
* @deprecated Use "charset" option to PDO MySQL Connection instead.
*/
class
MysqlSessionInit
implements
EventSubscriber
{
/**
* The charset.
*
* @var string
*/
private
$charset
;
/**
* The collation, or FALSE if no collation.
*
* @var string|bool
*/
private
$collation
;
/**
* Configure Charset and Collation options of MySQL Client for each Connection.
*
* @param string $charset The charset.
* @param string|bool $collation The collation, or FALSE if no collation.
*/
public
function
__construct
(
$charset
=
'utf8'
,
$collation
=
false
)
{
$this
->
charset
=
$charset
;
$this
->
collation
=
$collation
;
}
/**
* @return void
*/
public
function
postConnect
(
ConnectionEventArgs
$args
)
{
$collation
=
$this
->
collation
?
' COLLATE '
.
$this
->
collation
:
''
;
$args
->
getConnection
()
->
executeUpdate
(
'SET NAMES '
.
$this
->
charset
.
$collation
);
}
/**
* {@inheritdoc}
*/
public
function
getSubscribedEvents
()
{
return
[
Events
::
postConnect
];
}
}
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
a4158b5c
...
...
@@ -70,66 +70,6 @@ abstract class AbstractPlatform
public
const
CREATE_FOREIGNKEYS
=
2
;
/**
* @deprecated Use DateIntervalUnit::INTERVAL_UNIT_SECOND.
*/
public
const
DATE_INTERVAL_UNIT_SECOND
=
DateIntervalUnit
::
SECOND
;
/**
* @deprecated Use DateIntervalUnit::MINUTE.
*/
public
const
DATE_INTERVAL_UNIT_MINUTE
=
DateIntervalUnit
::
MINUTE
;
/**
* @deprecated Use DateIntervalUnit::HOUR.
*/
public
const
DATE_INTERVAL_UNIT_HOUR
=
DateIntervalUnit
::
HOUR
;
/**
* @deprecated Use DateIntervalUnit::DAY.
*/
public
const
DATE_INTERVAL_UNIT_DAY
=
DateIntervalUnit
::
DAY
;
/**
* @deprecated Use DateIntervalUnit::WEEK.
*/
public
const
DATE_INTERVAL_UNIT_WEEK
=
DateIntervalUnit
::
WEEK
;
/**
* @deprecated Use DateIntervalUnit::MONTH.
*/
public
const
DATE_INTERVAL_UNIT_MONTH
=
DateIntervalUnit
::
MONTH
;
/**
* @deprecated Use DateIntervalUnit::QUARTER.
*/
public
const
DATE_INTERVAL_UNIT_QUARTER
=
DateIntervalUnit
::
QUARTER
;
/**
* @deprecated Use DateIntervalUnit::QUARTER.
*/
public
const
DATE_INTERVAL_UNIT_YEAR
=
DateIntervalUnit
::
YEAR
;
/**
* @deprecated Use TrimMode::UNSPECIFIED.
*/
public
const
TRIM_UNSPECIFIED
=
TrimMode
::
UNSPECIFIED
;
/**
* @deprecated Use TrimMode::LEADING.
*/
public
const
TRIM_LEADING
=
TrimMode
::
LEADING
;
/**
* @deprecated Use TrimMode::TRAILING.
*/
public
const
TRIM_TRAILING
=
TrimMode
::
TRAILING
;
/**
* @deprecated Use TrimMode::BOTH.
*/
public
const
TRIM_BOTH
=
TrimMode
::
BOTH
;
/** @var string[]|null */
protected
$doctrineTypeMapping
=
null
;
...
...
@@ -3223,16 +3163,6 @@ abstract class AbstractPlatform
return
false
;
}
/**
* @deprecated
*
* @todo Remove in 3.0
*/
public
function
getIdentityColumnNullInsertSQL
()
{
return
''
;
}
/**
* Whether this platform supports views.
*
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
a4158b5c
...
...
@@ -290,22 +290,6 @@ class MySqlPlatform extends AbstractPlatform
return
'TINYINT(1)'
;
}
/**
* Obtain DBMS specific SQL code portion needed to set the COLLATION
* of a field declaration to be used in statements like CREATE TABLE.
*
* @deprecated Deprecated since version 2.5, Use {@link self::getColumnCollationDeclarationSQL()} instead.
*
* @param string $collation name of the collation
*
* @return string DBMS specific SQL code portion needed to set the COLLATION
* of a field declaration.
*/
public
function
getCollationFieldDeclaration
(
$collation
)
{
return
$this
->
getColumnCollationDeclarationSQL
(
$collation
);
}
/**
* {@inheritDoc}
*
...
...
lib/Doctrine/DBAL/SQLParserUtils.php
View file @
a4158b5c
...
...
@@ -28,13 +28,14 @@ use function substr;
*/
class
SQLParserUtils
{
private
const
POSITIONAL_TOKEN
=
'\?'
;
private
const
NAMED_TOKEN
=
'(?<!:):[a-zA-Z_][a-zA-Z0-9_]*'
;
/**#@+
* Quote characters within string literals can be preceded by a backslash.
*
* @deprecated Will be removed as internal implementation details.
*/
public
const
POSITIONAL_TOKEN
=
'\?'
;
public
const
NAMED_TOKEN
=
'(?<!:):[a-zA-Z_][a-zA-Z0-9_]*'
;
// Quote characters within string literals can be preceded by a backslash.
public
const
ESCAPED_SINGLE_QUOTED_TEXT
=
"(?:'(?:
\\\\\\\\
)+'|'(?:[^'
\\\\
]|
\\\\
'?|'')*')"
;
public
const
ESCAPED_DOUBLE_QUOTED_TEXT
=
'(?:"(?:\\\\\\\\)+"|"(?:[^"\\\\]|\\\\"?)*")'
;
public
const
ESCAPED_BACKTICK_QUOTED_TEXT
=
'(?:`(?:\\\\\\\\)+`|`(?:[^`\\\\]|\\\\`?)*`)'
;
...
...
@@ -42,26 +43,6 @@ class SQLParserUtils
private
const
ESCAPED_BRACKET_QUOTED_TEXT
=
'(?<!\b(?i:ARRAY))\[(?:[^\]])*\]'
;
/**
* Gets an array of the placeholders in an sql statements as keys and their positions in the query string.
*
* For a statement with positional parameters, returns a zero-indexed list of placeholder position.
* For a statement with named parameters, returns a map of placeholder positions to their parameter names.
*
* @deprecated Will be removed as internal implementation detail.
*
* @param string $statement
* @param bool $isPositional
*
* @return int[]|string[]
*/
public
static
function
getPlaceholderPositions
(
$statement
,
$isPositional
=
true
)
{
return
$isPositional
?
self
::
getPositionalPlaceholderPositions
(
$statement
)
:
self
::
getNamedPlaceholderPositions
(
$statement
);
}
/**
* Returns a zero-indexed list of placeholder position.
*
...
...
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
View file @
a4158b5c
...
...
@@ -236,16 +236,6 @@ abstract class AbstractSchemaManager
return
array_values
(
array_filter
(
$assetNames
,
$filter
));
}
/**
* @deprecated Use Configuration::getSchemaAssetsFilter() instead
*
* @return string|null
*/
protected
function
getFilterSchemaAssetsExpression
()
{
return
$this
->
_conn
->
getConfiguration
()
->
getFilterSchemaAssetsExpression
();
}
/**
* Lists the tables for this connection.
*
...
...
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
a4158b5c
...
...
@@ -10,7 +10,6 @@ use function array_key_exists;
use
function
array_keys
;
use
function
array_map
;
use
function
array_merge
;
use
function
array_shift
;
use
function
array_unique
;
use
function
assert
;
use
function
count
;
...
...
@@ -436,13 +435,6 @@ class Comparator
$changedProperties
[]
=
$property
;
}
// This is a very nasty hack to make comparator work with the legacy json_array type, which should be killed in v3
if
(
$this
->
isALegacyJsonComparison
(
$properties1
[
'type'
],
$properties2
[
'type'
]))
{
array_shift
(
$changedProperties
);
$changedProperties
[]
=
'comment'
;
}
// Null values need to be checked additionally as they tell whether to create or drop a default value.
// null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
if
((
$properties1
[
'default'
]
===
null
)
!==
(
$properties2
[
'default'
]
===
null
)
...
...
@@ -505,21 +497,6 @@ class Comparator
return
array_unique
(
$changedProperties
);
}
/**
* TODO: kill with fire on v3.0
*
* @deprecated
*/
private
function
isALegacyJsonComparison
(
Types\Type
$one
,
Types\Type
$other
)
:
bool
{
if
(
!
$one
instanceof
Types\JsonType
||
!
$other
instanceof
Types\JsonType
)
{
return
false
;
}
return
(
!
$one
instanceof
Types\JsonArrayType
&&
$other
instanceof
Types\JsonArrayType
)
||
(
!
$other
instanceof
Types\JsonArrayType
&&
$one
instanceof
Types\JsonArrayType
);
}
/**
* Finds the difference between the indexes $index1 and $index2.
*
...
...
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
a4158b5c
...
...
@@ -458,7 +458,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$column
->
setPlatformOption
(
'collation'
,
$tableColumn
[
'collation'
]);
}
if
(
in_array
(
$column
->
getType
()
->
getName
(),
[
Types
::
JSON_ARRAY
,
Types
::
JSON
],
true
)
)
{
if
(
$column
->
getType
()
->
getName
()
===
Types
::
JSON
)
{
$column
->
setPlatformOption
(
'jsonb'
,
$jsonb
);
}
...
...
lib/Doctrine/DBAL/Schema/Table.php
View file @
a4158b5c
...
...
@@ -303,25 +303,6 @@ class Table extends AbstractAsset
return
$column
;
}
/**
* Renames a Column.
*
* @deprecated
*
* @param string $oldColumnName
* @param string $newColumnName
*
* @throws DBALException
*/
public
function
renameColumn
(
$oldColumnName
,
$newColumnName
)
{
throw
new
DBALException
(
'Table#renameColumn() was removed, because it drops and recreates the column instead. '
.
'There is no fix available, because a schema diff cannot reliably detect if a column '
.
'was renamed or one column was created and another one dropped.'
);
}
/**
* Change Column Details.
*
...
...
@@ -364,59 +345,20 @@ class Table extends AbstractAsset
* @param string[] $localColumnNames
* @param string[] $foreignColumnNames
* @param mixed[] $options
* @param string|null $
constraintN
ame
* @param string|null $
n
ame
*
* @return self
*/
public
function
addForeignKeyConstraint
(
$foreignTable
,
array
$localColumnNames
,
array
$foreignColumnNames
,
array
$options
=
[],
$
constraintN
ame
=
null
)
public
function
addForeignKeyConstraint
(
$foreignTable
,
array
$localColumnNames
,
array
$foreignColumnNames
,
array
$options
=
[],
$
n
ame
=
null
)
{
if
(
!
$
constraintN
ame
)
{
$
constraintN
ame
=
$this
->
_generateIdentifierName
(
if
(
!
$
n
ame
)
{
$
n
ame
=
$this
->
_generateIdentifierName
(
array_merge
((
array
)
$this
->
getName
(),
$localColumnNames
),
'fk'
,
$this
->
_getMaxIdentifierLength
()
);
}
return
$this
->
addNamedForeignKeyConstraint
(
$constraintName
,
$foreignTable
,
$localColumnNames
,
$foreignColumnNames
,
$options
);
}
/**
* Adds a foreign key constraint.
*
* Name is to be generated by the database itself.
*
* @deprecated Use {@link addForeignKeyConstraint}
*
* @param Table|string $foreignTable Table schema instance or table name
* @param string[] $localColumnNames
* @param string[] $foreignColumnNames
* @param mixed[] $options
*
* @return self
*/
public
function
addUnnamedForeignKeyConstraint
(
$foreignTable
,
array
$localColumnNames
,
array
$foreignColumnNames
,
array
$options
=
[])
{
return
$this
->
addForeignKeyConstraint
(
$foreignTable
,
$localColumnNames
,
$foreignColumnNames
,
$options
);
}
/**
* Adds a foreign key constraint with a given name.
*
* @deprecated Use {@link addForeignKeyConstraint}
*
* @param string $name
* @param Table|string $foreignTable Table schema instance or table name
* @param string[] $localColumnNames
* @param string[] $foreignColumnNames
* @param mixed[] $options
*
* @return self
*
* @throws SchemaException
*/
public
function
addNamedForeignKeyConstraint
(
$name
,
$foreignTable
,
array
$localColumnNames
,
array
$foreignColumnNames
,
array
$options
=
[])
{
if
(
$foreignTable
instanceof
Table
)
{
foreach
(
$foreignColumnNames
as
$columnName
)
{
if
(
!
$foreignTable
->
hasColumn
(
$columnName
))
{
...
...
lib/Doctrine/DBAL/Types/JsonArrayType.php
deleted
100644 → 0
View file @
ff1bc0d7
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
function
is_resource
;
use
function
json_decode
;
use
function
stream_get_contents
;
/**
* Array Type which can be used to generate json arrays.
*
* @deprecated Use JsonType instead
*/
class
JsonArrayType
extends
JsonType
{
/**
* {@inheritdoc}
*/
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
if
(
$value
===
null
||
$value
===
''
)
{
return
[];
}
$value
=
is_resource
(
$value
)
?
stream_get_contents
(
$value
)
:
$value
;
return
json_decode
(
$value
,
true
);
}
/**
* {@inheritdoc}
*/
public
function
getName
()
{
return
Types
::
JSON_ARRAY
;
}
/**
* {@inheritdoc}
*/
public
function
requiresSQLCommentHint
(
AbstractPlatform
$platform
)
{
return
true
;
}
}
lib/Doctrine/DBAL/Types/Type.php
View file @
a4158b5c
...
...
@@ -65,9 +65,6 @@ abstract class Type
/** @deprecated Use {@see DefaultTypes::JSON} instead. */
public
const
JSON
=
Types
::
JSON
;
/** @deprecated Use {@see DefaultTypes::JSON_ARRAY} instead. */
public
const
JSON_ARRAY
=
Types
::
JSON_ARRAY
;
/** @deprecated Use {@see DefaultTypes::OBJECT} instead. */
public
const
OBJECT
=
Types
::
OBJECT
;
...
...
@@ -113,7 +110,6 @@ abstract class Type
Types
::
GUID
=>
GuidType
::
class
,
Types
::
INTEGER
=>
IntegerType
::
class
,
Types
::
JSON
=>
JsonType
::
class
,
Types
::
JSON_ARRAY
=>
JsonArrayType
::
class
,
Types
::
OBJECT
=>
ObjectType
::
class
,
Types
::
SIMPLE_ARRAY
=>
SimpleArrayType
::
class
,
Types
::
SMALLINT
=>
SmallIntType
::
class
,
...
...
tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php
deleted
100644 → 0
View file @
ff1bc0d7
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\Tests\DBAL\Events
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Event\ConnectionEventArgs
;
use
Doctrine\DBAL\Event\Listeners\MysqlSessionInit
;
use
Doctrine\DBAL\Events
;
use
Doctrine\Tests\DbalTestCase
;
class
MysqlSessionInitTest
extends
DbalTestCase
{
public
function
testPostConnect
()
:
void
{
$connectionMock
=
$this
->
createMock
(
Connection
::
class
);
$connectionMock
->
expects
(
$this
->
once
())
->
method
(
'executeUpdate'
)
->
with
(
$this
->
equalTo
(
'SET NAMES foo COLLATE bar'
));
$eventArgs
=
new
ConnectionEventArgs
(
$connectionMock
);
$listener
=
new
MysqlSessionInit
(
'foo'
,
'bar'
);
$listener
->
postConnect
(
$eventArgs
);
}
public
function
testGetSubscribedEvents
()
:
void
{
$listener
=
new
MysqlSessionInit
();
self
::
assertEquals
([
Events
::
postConnect
],
$listener
->
getSubscribedEvents
());
}
}
tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
View file @
a4158b5c
...
...
@@ -18,6 +18,7 @@ use Doctrine\DBAL\Types\Types;
use
function
array_map
;
use
function
array_pop
;
use
function
count
;
use
function
preg_match
;
use
function
strtolower
;
class
PostgreSqlSchemaManagerTest
extends
SchemaManagerFunctionalTestCase
...
...
@@ -30,7 +31,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
return
;
}
$this
->
connection
->
getConfiguration
()
->
set
FilterSchemaAssetsExpression
(
null
);
$this
->
connection
->
getConfiguration
()
->
set
SchemaAssetsFilter
(
null
);
}
/**
...
...
@@ -161,7 +162,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$column
=
$nestedSchemaTable
->
addColumn
(
'id'
,
'integer'
);
$column
->
setAutoincrement
(
true
);
$nestedSchemaTable
->
setPrimaryKey
([
'id'
]);
$nestedSchemaTable
->
add
Unnamed
ForeignKeyConstraint
(
$nestedRelatedTable
,
[
'id'
],
[
'id'
]);
$nestedSchemaTable
->
addForeignKeyConstraint
(
$nestedRelatedTable
,
[
'id'
],
[
'id'
]);
$this
->
schemaManager
->
createTable
(
$nestedRelatedTable
);
$this
->
schemaManager
->
createTable
(
$nestedSchemaTable
);
...
...
@@ -214,11 +215,15 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$column
=
$testTable
->
addColumn
(
'id'
,
'integer'
);
$this
->
schemaManager
->
createTable
(
$testTable
);
$this
->
connection
->
getConfiguration
()
->
setFilterSchemaAssetsExpression
(
'#^dbal204_#'
);
$this
->
connection
->
getConfiguration
()
->
setSchemaAssetsFilter
(
static
function
(
string
$name
)
:
bool
{
return
preg_match
(
'#^dbal204_#'
,
$name
)
===
1
;
});
$names
=
$this
->
schemaManager
->
listTableNames
();
self
::
assertCount
(
2
,
$names
);
$this
->
connection
->
getConfiguration
()
->
setFilterSchemaAssetsExpression
(
'#^dbal204_test#'
);
$this
->
connection
->
getConfiguration
()
->
setSchemaAssetsFilter
(
static
function
(
string
$name
)
:
bool
{
return
preg_match
(
'#^dbal204_test#'
,
$name
)
===
1
;
});
$names
=
$this
->
schemaManager
->
listTableNames
();
self
::
assertCount
(
1
,
$names
);
}
...
...
@@ -386,10 +391,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self
::
assertSame
(
'(id IS NULL)'
,
$onlineTable
->
getIndex
(
'simple_partial_index'
)
->
getOption
(
'where'
));
}
/**
* @dataProvider jsonbColumnTypeProvider
*/
public
function
testJsonbColumn
(
string
$type
)
:
void
public
function
testJsonbColumn
()
:
void
{
if
(
!
$this
->
schemaManager
->
getDatabasePlatform
()
instanceof
PostgreSQL94Platform
)
{
$this
->
markTestSkipped
(
'Requires PostgresSQL 9.4+'
);
...
...
@@ -398,26 +400,15 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
}
$table
=
new
Schema\Table
(
'test_jsonb'
);
$table
->
addColumn
(
'foo'
,
$type
)
->
setPlatformOption
(
'jsonb'
,
true
);
$table
->
addColumn
(
'foo'
,
Types
::
JSON
)
->
setPlatformOption
(
'jsonb'
,
true
);
$this
->
schemaManager
->
dropAndCreateTable
(
$table
);
$columns
=
$this
->
schemaManager
->
listTableColumns
(
'test_jsonb'
);
self
::
assertSame
(
$type
,
$columns
[
'foo'
]
->
getType
()
->
getName
());
self
::
assertSame
(
Types
::
JSON
,
$columns
[
'foo'
]
->
getType
()
->
getName
());
self
::
assertTrue
(
$columns
[
'foo'
]
->
getPlatformOption
(
'jsonb'
));
}
/**
* @return mixed[][]
*/
public
function
jsonbColumnTypeProvider
()
:
array
{
return
[
[
Types
::
JSON
],
[
Types
::
JSON_ARRAY
],
];
}
/**
* @group DBAL-2427
*/
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
a4158b5c
...
...
@@ -1311,129 +1311,6 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
self
::
assertArrayHasKey
(
'idx_3d6c147fdc58d6c'
,
$indexes
);
}
/**
* @after
*/
public
function
removeJsonArrayTable
()
:
void
{
if
(
!
$this
->
schemaManager
->
tablesExist
([
'json_array_test'
]))
{
return
;
}
$this
->
schemaManager
->
dropTable
(
'json_array_test'
);
}
/**
* @group 2782
* @group 6654
*/
public
function
testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComment
()
:
void
{
$table
=
new
Table
(
'json_array_test'
);
$table
->
addColumn
(
'parameters'
,
'json_array'
);
$this
->
schemaManager
->
createTable
(
$table
);
$comparator
=
new
Comparator
();
$tableDiff
=
$comparator
->
diffTable
(
$this
->
schemaManager
->
listTableDetails
(
'json_array_test'
),
$table
);
self
::
assertFalse
(
$tableDiff
);
}
/**
* @group 2782
* @group 6654
*/
public
function
testComparatorShouldModifyOnlyTheCommentWhenUpdatingFromJsonArrayTypeOnLegacyPlatforms
()
:
void
{
if
(
$this
->
schemaManager
->
getDatabasePlatform
()
->
hasNativeJsonType
())
{
$this
->
markTestSkipped
(
'This test is only supported on platforms that do not have native JSON type.'
);
}
$table
=
new
Table
(
'json_array_test'
);
$table
->
addColumn
(
'parameters'
,
'json_array'
);
$this
->
schemaManager
->
createTable
(
$table
);
$table
=
new
Table
(
'json_array_test'
);
$table
->
addColumn
(
'parameters'
,
'json'
);
$comparator
=
new
Comparator
();
$tableDiff
=
$comparator
->
diffTable
(
$this
->
schemaManager
->
listTableDetails
(
'json_array_test'
),
$table
);
self
::
assertInstanceOf
(
TableDiff
::
class
,
$tableDiff
);
$changedColumn
=
$tableDiff
->
changedColumns
[
'parameters'
]
??
$tableDiff
->
changedColumns
[
'PARAMETERS'
];
self
::
assertSame
([
'comment'
],
$changedColumn
->
changedProperties
);
}
/**
* @group 2782
* @group 6654
*/
public
function
testComparatorShouldAddCommentToLegacyJsonArrayTypeThatDoesNotHaveIt
()
:
void
{
if
(
!
$this
->
schemaManager
->
getDatabasePlatform
()
->
hasNativeJsonType
())
{
$this
->
markTestSkipped
(
'This test is only supported on platforms that have native JSON type.'
);
}
$this
->
connection
->
executeQuery
(
'CREATE TABLE json_array_test (parameters JSON NOT NULL)'
);
$table
=
new
Table
(
'json_array_test'
);
$table
->
addColumn
(
'parameters'
,
'json_array'
);
$comparator
=
new
Comparator
();
$tableDiff
=
$comparator
->
diffTable
(
$this
->
schemaManager
->
listTableDetails
(
'json_array_test'
),
$table
);
self
::
assertInstanceOf
(
TableDiff
::
class
,
$tableDiff
);
self
::
assertSame
([
'comment'
],
$tableDiff
->
changedColumns
[
'parameters'
]
->
changedProperties
);
}
/**
* @group 2782
* @group 6654
*/
public
function
testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType
()
:
void
{
if
(
!
$this
->
schemaManager
->
getDatabasePlatform
()
->
hasNativeJsonType
())
{
$this
->
markTestSkipped
(
'This test is only supported on platforms that have native JSON type.'
);
}
$this
->
connection
->
executeQuery
(
'CREATE TABLE json_array_test (parameters JSON DEFAULT NULL)'
);
$table
=
new
Table
(
'json_array_test'
);
$table
->
addColumn
(
'parameters'
,
'json_array'
);
$comparator
=
new
Comparator
();
$tableDiff
=
$comparator
->
diffTable
(
$this
->
schemaManager
->
listTableDetails
(
'json_array_test'
),
$table
);
self
::
assertInstanceOf
(
TableDiff
::
class
,
$tableDiff
);
self
::
assertSame
([
'notnull'
,
'comment'
],
$tableDiff
->
changedColumns
[
'parameters'
]
->
changedProperties
);
}
/**
* @group 2782
* @group 6654
*/
public
function
testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayTypeEvenWhenPlatformHasJsonSupport
()
:
void
{
if
(
!
$this
->
schemaManager
->
getDatabasePlatform
()
->
hasNativeJsonType
())
{
$this
->
markTestSkipped
(
'This test is only supported on platforms that have native JSON type.'
);
}
$this
->
connection
->
executeQuery
(
'CREATE TABLE json_array_test (parameters JSON DEFAULT NULL)'
);
$table
=
new
Table
(
'json_array_test'
);
$table
->
addColumn
(
'parameters'
,
'json_array'
);
$comparator
=
new
Comparator
();
$tableDiff
=
$comparator
->
diffTable
(
$this
->
schemaManager
->
listTableDetails
(
'json_array_test'
),
$table
);
self
::
assertInstanceOf
(
TableDiff
::
class
,
$tableDiff
);
self
::
assertSame
([
'notnull'
,
'comment'
],
$tableDiff
->
changedColumns
[
'parameters'
]
->
changedProperties
);
}
/**
* @group 2782
* @group 6654
...
...
tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
View file @
a4158b5c
...
...
@@ -33,7 +33,7 @@ class TypeConversionTest extends DbalFunctionalTestCase
$table
->
addColumn
(
'test_time'
,
'time'
,
[
'notnull'
=>
false
]);
$table
->
addColumn
(
'test_text'
,
'text'
,
[
'notnull'
=>
false
]);
$table
->
addColumn
(
'test_array'
,
'array'
,
[
'notnull'
=>
false
]);
$table
->
addColumn
(
'test_json
_array'
,
'json_array
'
,
[
'notnull'
=>
false
]);
$table
->
addColumn
(
'test_json
'
,
'json
'
,
[
'notnull'
=>
false
]);
$table
->
addColumn
(
'test_object'
,
'object'
,
[
'notnull'
=>
false
]);
$table
->
addColumn
(
'test_float'
,
'float'
,
[
'notnull'
=>
false
]);
$table
->
addColumn
(
'test_decimal'
,
'decimal'
,
[
'notnull'
=>
false
,
'scale'
=>
2
,
'precision'
=>
10
]);
...
...
@@ -166,7 +166,7 @@ class TypeConversionTest extends DbalFunctionalTestCase
{
return
[
'array'
=>
[
'array'
,
[
'foo'
=>
'bar'
]],
'json
_array'
=>
[
'json_array
'
,
[
'foo'
=>
'bar'
]],
'json
'
=>
[
'json
'
,
[
'foo'
=>
'bar'
]],
];
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
a4158b5c
...
...
@@ -880,7 +880,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
$column
=
[
'length'
=>
666
,
'notnull'
=>
true
,
'type'
=>
Type
::
getType
(
'json
_array
'
),
'type'
=>
Type
::
getType
(
'json'
),
];
self
::
assertSame
(
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
View file @
a4158b5c
...
...
@@ -585,7 +585,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
$oldTable
=
clone
$newTable
;
$oldTable
->
addColumn
(
'parent_id'
,
'integer'
);
$oldTable
->
add
Unnamed
ForeignKeyConstraint
(
'mytable'
,
[
'parent_id'
],
[
'id'
]);
$oldTable
->
addForeignKeyConstraint
(
'mytable'
,
[
'parent_id'
],
[
'id'
]);
$comparator
=
new
Comparator
();
$tableDiff
=
$comparator
->
diffTable
(
$oldTable
,
$newTable
);
...
...
tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
View file @
a4158b5c
This diff is collapsed.
Click to expand it.
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
a4158b5c
...
...
@@ -681,11 +681,11 @@ class ComparatorTest extends TestCase
{
$tableA
=
new
Table
(
'foo'
);
$tableA
->
addColumn
(
'id'
,
'integer'
);
$tableA
->
add
NamedForeignKeyConstraint
(
'foo_constraint'
,
'bar'
,
[
'id'
],
[
'id'
]
);
$tableA
->
add
ForeignKeyConstraint
(
'bar'
,
[
'id'
],
[
'id'
],
[],
'foo_constraint'
);
$tableB
=
new
Table
(
'foo'
);
$tableB
->
addColumn
(
'ID'
,
'integer'
);
$tableB
->
add
NamedForeignKeyConstraint
(
'bar_constraint'
,
'bar'
,
[
'id'
],
[
'id'
]
);
$tableB
->
add
ForeignKeyConstraint
(
'bar'
,
[
'id'
],
[
'id'
],
[],
'bar_constraint'
);
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
...
...
tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
View file @
a4158b5c
...
...
@@ -13,6 +13,7 @@ use Doctrine\DBAL\Schema\DB2SchemaManager;
use
PHPUnit\Framework\MockObject\MockObject
;
use
PHPUnit\Framework\TestCase
;
use
function
in_array
;
use
function
preg_match
;
/**
* @covers \Doctrine\DBAL\Schema\DB2SchemaManager
...
...
@@ -50,7 +51,9 @@ final class DB2SchemaManagerTest extends TestCase
*/
public
function
testListTableNamesFiltersAssetNamesCorrectly
()
:
void
{
$this
->
conn
->
getConfiguration
()
->
setFilterSchemaAssetsExpression
(
'/^(?!T_)/'
);
$this
->
conn
->
getConfiguration
()
->
setSchemaAssetsFilter
(
static
function
(
string
$name
)
:
bool
{
return
preg_match
(
'/^(?!T_)/'
,
$name
)
===
1
;
});
$this
->
conn
->
expects
(
$this
->
once
())
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
([
[
'name'
=>
'FOO'
],
[
'name'
=>
'T_FOO'
],
...
...
@@ -67,35 +70,6 @@ final class DB2SchemaManagerTest extends TestCase
);
}
/**
* @group DBAL-2701
*/
public
function
testAssetFilteringSetsACallable
()
:
void
{
$filterExpression
=
'/^(?!T_)/'
;
$this
->
conn
->
getConfiguration
()
->
setFilterSchemaAssetsExpression
(
$filterExpression
);
$this
->
conn
->
expects
(
$this
->
once
())
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
([
[
'name'
=>
'FOO'
],
[
'name'
=>
'T_FOO'
],
[
'name'
=>
'BAR'
],
[
'name'
=>
'T_BAR'
],
]));
self
::
assertSame
(
[
'FOO'
,
'BAR'
,
],
$this
->
manager
->
listTableNames
()
);
$callable
=
$this
->
conn
->
getConfiguration
()
->
getSchemaAssetsFilter
();
self
::
assertIsCallable
(
$callable
);
// BC check: Test that regexp expression is still preserved & accessible.
$this
->
assertEquals
(
$filterExpression
,
$this
->
conn
->
getConfiguration
()
->
getFilterSchemaAssetsExpression
());
}
public
function
testListTableNamesFiltersAssetNamesCorrectlyWithCallable
()
:
void
{
$accepted
=
[
'T_FOO'
,
'T_BAR'
];
...
...
@@ -117,79 +91,5 @@ final class DB2SchemaManagerTest extends TestCase
],
$this
->
manager
->
listTableNames
()
);
$this
->
assertNull
(
$this
->
conn
->
getConfiguration
()
->
getFilterSchemaAssetsExpression
());
}
public
function
testSettingNullExpressionWillResetCallable
()
:
void
{
$accepted
=
[
'T_FOO'
,
'T_BAR'
];
$this
->
conn
->
getConfiguration
()
->
setSchemaAssetsFilter
(
static
function
(
$assetName
)
use
(
$accepted
)
{
return
in_array
(
$assetName
,
$accepted
);
});
$this
->
conn
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
([
[
'name'
=>
'FOO'
],
[
'name'
=>
'T_FOO'
],
[
'name'
=>
'BAR'
],
[
'name'
=>
'T_BAR'
],
]));
self
::
assertSame
(
[
'T_FOO'
,
'T_BAR'
,
],
$this
->
manager
->
listTableNames
()
);
$this
->
conn
->
getConfiguration
()
->
setFilterSchemaAssetsExpression
(
null
);
self
::
assertSame
(
[
'FOO'
,
'T_FOO'
,
'BAR'
,
'T_BAR'
,
],
$this
->
manager
->
listTableNames
()
);
$this
->
assertNull
(
$this
->
conn
->
getConfiguration
()
->
getSchemaAssetsFilter
());
}
public
function
testSettingNullAsCallableClearsExpression
()
:
void
{
$filterExpression
=
'/^(?!T_)/'
;
$this
->
conn
->
getConfiguration
()
->
setFilterSchemaAssetsExpression
(
$filterExpression
);
$this
->
conn
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
([
[
'name'
=>
'FOO'
],
[
'name'
=>
'T_FOO'
],
[
'name'
=>
'BAR'
],
[
'name'
=>
'T_BAR'
],
]));
self
::
assertSame
(
[
'FOO'
,
'BAR'
,
],
$this
->
manager
->
listTableNames
()
);
$this
->
conn
->
getConfiguration
()
->
setSchemaAssetsFilter
(
null
);
self
::
assertSame
(
[
'FOO'
,
'T_FOO'
,
'BAR'
,
'T_BAR'
,
],
$this
->
manager
->
listTableNames
()
);
$this
->
assertNull
(
$this
->
conn
->
getConfiguration
()
->
getFilterSchemaAssetsExpression
());
}
}
tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php
View file @
a4158b5c
...
...
@@ -53,7 +53,7 @@ class MySQLSchemaTest extends TestCase
{
$tableOld
=
new
Table
(
'test'
);
$tableOld
->
addColumn
(
'foo_id'
,
'integer'
);
$tableOld
->
add
Unnamed
ForeignKeyConstraint
(
'test_foreign'
,
[
'foo_id'
],
[
'foo_id'
]);
$tableOld
->
addForeignKeyConstraint
(
'test_foreign'
,
[
'foo_id'
],
[
'foo_id'
]);
$sqls
=
[];
foreach
(
$tableOld
->
getForeignKeys
()
as
$fk
)
{
...
...
tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
deleted
100644 → 0
View file @
ff1bc0d7
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\ParameterType
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\JsonArrayType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Types\Types
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
function
base64_encode
;
use
function
fopen
;
use
function
json_encode
;
class
JsonArrayTest
extends
DbalTestCase
{
/** @var AbstractPlatform|MockObject */
protected
$platform
;
/** @var JsonArrayType */
protected
$type
;
/**
* {@inheritdoc}
*/
protected
function
setUp
()
:
void
{
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'json_array'
);
}
public
function
testReturnsBindingType
()
:
void
{
self
::
assertSame
(
ParameterType
::
STRING
,
$this
->
type
->
getBindingType
());
}
public
function
testReturnsName
()
:
void
{
self
::
assertSame
(
Types
::
JSON_ARRAY
,
$this
->
type
->
getName
());
}
public
function
testReturnsSQLDeclaration
()
:
void
{
$this
->
platform
->
expects
(
$this
->
once
())
->
method
(
'getJsonTypeDeclarationSQL'
)
->
willReturn
(
'TEST_JSON'
);
self
::
assertSame
(
'TEST_JSON'
,
$this
->
type
->
getSQLDeclaration
([],
$this
->
platform
));
}
public
function
testJsonNullConvertsToPHPValue
()
:
void
{
self
::
assertSame
([],
$this
->
type
->
convertToPHPValue
(
null
,
$this
->
platform
));
}
public
function
testJsonEmptyStringConvertsToPHPValue
()
:
void
{
self
::
assertSame
([],
$this
->
type
->
convertToPHPValue
(
''
,
$this
->
platform
));
}
public
function
testJsonStringConvertsToPHPValue
()
:
void
{
$value
=
[
'foo'
=>
'bar'
,
'bar'
=>
'foo'
];
$databaseValue
=
json_encode
(
$value
);
$phpValue
=
$this
->
type
->
convertToPHPValue
(
$databaseValue
,
$this
->
platform
);
self
::
assertEquals
(
$value
,
$phpValue
);
}
public
function
testJsonResourceConvertsToPHPValue
()
:
void
{
$value
=
[
'foo'
=>
'bar'
,
'bar'
=>
'foo'
];
$databaseValue
=
fopen
(
'data://text/plain;base64,'
.
base64_encode
(
json_encode
(
$value
)),
'r'
);
$phpValue
=
$this
->
type
->
convertToPHPValue
(
$databaseValue
,
$this
->
platform
);
self
::
assertSame
(
$value
,
$phpValue
);
}
public
function
testRequiresSQLCommentHint
()
:
void
{
self
::
assertTrue
(
$this
->
type
->
requiresSQLCommentHint
(
$this
->
platform
));
}
}
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