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