From 4fdbdabae4d5ca3bb5b40b8176ab6e7e82999c01 Mon Sep 17 00:00:00 2001
From: Gocha Ossinkine <ossinkine@ya.ru>
Date: Thu, 28 Sep 2017 12:03:37 +0500
Subject: [PATCH] Add DateInterval type parameter

---
 composer.json                                               | 2 +-
 lib/Doctrine/ORM/Query/ParameterTypeInferer.php             | 4 ++++
 tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php | 5 +++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/composer.json b/composer.json
index e738e05ee..b4371aaec 100644
--- a/composer.json
+++ b/composer.json
@@ -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",
diff --git a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php
index 597c7e2ea..07b78f008 100644
--- a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php
+++ b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php
@@ -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
diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php
index b929f8d18..35e9bf2f5 100644
--- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php
+++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php
@@ -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];