From 30ddeb447646ae5cb153e7efc31de1a3f0b90ad1 Mon Sep 17 00:00:00 2001
From: pbarroca <pbarroca@git-test.afi-sa.fr>
Date: Mon, 7 May 2012 15:26:00 +0000
Subject: [PATCH] OAI: Correction requetage sur les dates

---
 library/Class/Catalogue.php           | 4 ++--
 tests/library/Class/CatalogueTest.php | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php
index 0c31d85ae0e..d04657d6158 100644
--- a/library/Class/Catalogue.php
+++ b/library/Class/Catalogue.php
@@ -173,10 +173,10 @@ class CatalogueLoader extends Storm_Model_Loader {
 	public function fromUntilClauseFor($catalogue) {
 		$clauses = array();
 		if ($start = $catalogue->getFrom()) 
-			$clauses[] = "date_maj >= '" . $start . "'";
+			$clauses[] = "left(date_maj, 10) >= '" . $start . "'";
 
 		if($end = $catalogue->getUntil()) 
-			$clauses[] = "date_maj <= '" . $end . "'";
+			$clauses[] = "left(date_maj, 10) <= '" . $end . "'";
 
 		if (0 == count($clauses))
 			return '';
diff --git a/tests/library/Class/CatalogueTest.php b/tests/library/Class/CatalogueTest.php
index 63c53a69ef8..a9842b8d2e6 100644
--- a/tests/library/Class/CatalogueTest.php
+++ b/tests/library/Class/CatalogueTest.php
@@ -238,7 +238,7 @@ class CatalogueTestGetPagedNotices extends ModelTestCase {
 	/** @test */
 	public function withFromShouldQueryOnDateMaj() {
 		$this->_catalogue->setFrom('2011-03-05');
-		$this->_expectNoticeFindAllBy('date_maj >= \'2011-03-05\'');
+		$this->_expectNoticeFindAllBy('left(date_maj, 10) >= \'2011-03-05\'');
 		Class_Catalogue::getLoader()->loadNoticesFor($this->_catalogue);
 	}
 
@@ -246,7 +246,7 @@ class CatalogueTestGetPagedNotices extends ModelTestCase {
 	/** @test */
 	public function withUntilShouldQueryOnDateMaj() {
 		$this->_catalogue->setUntil('2011-03-05');
-		$this->_expectNoticeFindAllBy('date_maj <= \'2011-03-05\'');
+		$this->_expectNoticeFindAllBy('left(date_maj, 10) <= \'2011-03-05\'');
 		Class_Catalogue::getLoader()->loadNoticesFor($this->_catalogue);
 	}
 
-- 
GitLab