Merge pull request #6734 from ossinkine/issue-6734
Add DateInterval type parameter
This commit is contained in:
commit
8e16748ff8
@ -17,7 +17,7 @@
|
||||
"php": "^7.1",
|
||||
"ext-pdo": "*",
|
||||
"doctrine/collections": "^1.4",
|
||||
"doctrine/dbal": ">=2.5-dev,<2.7-dev",
|
||||
"doctrine/dbal": "^2.6",
|
||||
"doctrine/instantiator": "~1.1",
|
||||
"doctrine/common": "^2.7.1",
|
||||
"doctrine/cache": "~1.6",
|
||||
|
@ -57,6 +57,10 @@ class ParameterTypeInferer
|
||||
return Type::DATETIME;
|
||||
}
|
||||
|
||||
if ($value instanceof \DateInterval) {
|
||||
return Type::DATEINTERVAL;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
return is_int(current($value))
|
||||
? Connection::PARAM_INT_ARRAY
|
||||
|
@ -13,17 +13,18 @@ class ParameterTypeInfererTest extends OrmTestCase
|
||||
|
||||
public function providerParameterTypeInferer()
|
||||
{
|
||||
$data = [
|
||||
$data = [
|
||||
[1, Type::INTEGER],
|
||||
["bar", PDO::PARAM_STR],
|
||||
["1", PDO::PARAM_STR],
|
||||
[new \DateTime, Type::DATETIME],
|
||||
[new \DateInterval('P1D'), Type::DATEINTERVAL],
|
||||
[[2], Connection::PARAM_INT_ARRAY],
|
||||
[["foo"], Connection::PARAM_STR_ARRAY],
|
||||
[["1","2"], Connection::PARAM_STR_ARRAY],
|
||||
[[], Connection::PARAM_STR_ARRAY],
|
||||
[true, Type::BOOLEAN],
|
||||
];
|
||||
];
|
||||
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$data[] = [new \DateTimeImmutable(), Type::DATETIME];
|
||||
|
Loading…
x
Reference in New Issue
Block a user