1
0
mirror of synced 2025-02-02 13:31:45 +03:00

Add DateInterval type parameter

This commit is contained in:
Gocha Ossinkine 2017-09-28 12:03:37 +05:00
parent 53245e8a73
commit 4fdbdabae4
3 changed files with 8 additions and 3 deletions

View File

@ -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",

View File

@ -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

View File

@ -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];