From e97569a15321effb1ee921a8cdaf780029e1e7eb Mon Sep 17 00:00:00 2001 From: Tomek Date: Tue, 29 Jan 2013 00:06:31 +0100 Subject: [PATCH 1/5] implement skip in findBy Repository method --- src/Doctrine/ODM/OrientDB/Repository.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Doctrine/ODM/OrientDB/Repository.php b/src/Doctrine/ODM/OrientDB/Repository.php index 5100cea..6689069 100644 --- a/src/Doctrine/ODM/OrientDB/Repository.php +++ b/src/Doctrine/ODM/OrientDB/Repository.php @@ -145,6 +145,10 @@ public function findBy(array $criteria, array $orderBy = array(), $limit = null, $query->orderBy("$key $order"); } + if ($offset) { + $query->skip($offset); + } + if ($limit) { $query->limit($limit); } From 78be018d5bbe1226040f9a121da96d6020423740 Mon Sep 17 00:00:00 2001 From: Tomek Date: Tue, 29 Jan 2013 02:42:33 +0100 Subject: [PATCH 2/5] fix casting if value from OrienDB is NULL --- src/Doctrine/ODM/OrientDB/Caster/Caster.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Doctrine/ODM/OrientDB/Caster/Caster.php b/src/Doctrine/ODM/OrientDB/Caster/Caster.php index 5d50c35..a9a422f 100644 --- a/src/Doctrine/ODM/OrientDB/Caster/Caster.php +++ b/src/Doctrine/ODM/OrientDB/Caster/Caster.php @@ -71,7 +71,7 @@ public function __construct(Mapper $mapper, $value = null, $dateClass = "\DateTi */ public function castBoolean() { - if (is_bool($this->value)) { + if (is_bool($this->value) || $this->value === null) { return $this->value; } @@ -187,7 +187,7 @@ public function castDecimal() return (float) $value; }; - if (is_numeric($this->value)) { + if (is_numeric($this->value) || $this->value === null) { return $castFunction($this->value); } else { return $this->handleMismatch($castFunction, 'decimal'); @@ -257,7 +257,7 @@ public function castFloat() return (float) $value; }; - if (is_numeric($this->value)) { + if (is_numeric($this->value) || $this->value === null) { return $castFunction($this->value); } else { return $this->handleMismatch($castFunction, 'double'); @@ -275,7 +275,7 @@ public function castInteger() return is_object($value) ? 1 : (int) $value; }; - if (is_numeric($this->value)) { + if (is_numeric($this->value) || $this->value === null) { return $castFunction($this->value); } else { return $this->handleMismatch($castFunction, 'integer'); @@ -383,7 +383,7 @@ public function castString() return is_array($value) ? 'Array' : (string) $value; }; - if (is_string($this->value)) { + if (is_string($this->value) || $this->value === null) { return $castFunction($this->value); } else { return $this->handleMismatch($castFunction, 'string'); From 1dbfaa4d62b446608d5a8dff2a6fb1b55d685fbf Mon Sep 17 00:00:00 2001 From: Tomek Date: Tue, 29 Jan 2013 03:06:13 +0100 Subject: [PATCH 3/5] reverted changes --- src/Doctrine/ODM/OrientDB/Caster/Caster.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Doctrine/ODM/OrientDB/Caster/Caster.php b/src/Doctrine/ODM/OrientDB/Caster/Caster.php index a9a422f..5d50c35 100644 --- a/src/Doctrine/ODM/OrientDB/Caster/Caster.php +++ b/src/Doctrine/ODM/OrientDB/Caster/Caster.php @@ -71,7 +71,7 @@ public function __construct(Mapper $mapper, $value = null, $dateClass = "\DateTi */ public function castBoolean() { - if (is_bool($this->value) || $this->value === null) { + if (is_bool($this->value)) { return $this->value; } @@ -187,7 +187,7 @@ public function castDecimal() return (float) $value; }; - if (is_numeric($this->value) || $this->value === null) { + if (is_numeric($this->value)) { return $castFunction($this->value); } else { return $this->handleMismatch($castFunction, 'decimal'); @@ -257,7 +257,7 @@ public function castFloat() return (float) $value; }; - if (is_numeric($this->value) || $this->value === null) { + if (is_numeric($this->value)) { return $castFunction($this->value); } else { return $this->handleMismatch($castFunction, 'double'); @@ -275,7 +275,7 @@ public function castInteger() return is_object($value) ? 1 : (int) $value; }; - if (is_numeric($this->value) || $this->value === null) { + if (is_numeric($this->value)) { return $castFunction($this->value); } else { return $this->handleMismatch($castFunction, 'integer'); @@ -383,7 +383,7 @@ public function castString() return is_array($value) ? 'Array' : (string) $value; }; - if (is_string($this->value) || $this->value === null) { + if (is_string($this->value)) { return $castFunction($this->value); } else { return $this->handleMismatch($castFunction, 'string'); From 8459cb47596907f0c17d764cd56f4f433a9b7f9c Mon Sep 17 00:00:00 2001 From: Tomek Date: Thu, 31 Jan 2013 00:41:23 +0100 Subject: [PATCH 4/5] integration test for skip --- test/Doctrine/ODM/OrientDB/Integration/RepositoryTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Doctrine/ODM/OrientDB/Integration/RepositoryTest.php b/test/Doctrine/ODM/OrientDB/Integration/RepositoryTest.php index 8c924d3..7b3a2d8 100644 --- a/test/Doctrine/ODM/OrientDB/Integration/RepositoryTest.php +++ b/test/Doctrine/ODM/OrientDB/Integration/RepositoryTest.php @@ -91,6 +91,11 @@ public function testRetrievingByCriteria() $posts = $repository->findBy(array(), array('@rid' => 'ASC'), 1); $this->assertCount(1, $posts); + + $post0Rid = $posts[0]->getRid(); + $posts = $repository->findBy(array(), array('@rid' => 'ASC'), 4, 1); + $this->assertCount(3, $posts); + $this->assertTrue($posts[0]->getRid() != $post0Rid); } public function testRetrievingARecordByCriteria() From dcddc4a392e7392a628e9edddb8bcc1c5d780739 Mon Sep 17 00:00:00 2001 From: Tomek Date: Thu, 31 Jan 2013 03:49:35 +0100 Subject: [PATCH 5/5] added status_continue to valid statuses --- .../OrientDB/Binding/Client/Http/CurlClientResponse.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Doctrine/OrientDB/Binding/Client/Http/CurlClientResponse.php b/src/Doctrine/OrientDB/Binding/Client/Http/CurlClientResponse.php index f34d2ed..0d248f5 100644 --- a/src/Doctrine/OrientDB/Binding/Client/Http/CurlClientResponse.php +++ b/src/Doctrine/OrientDB/Binding/Client/Http/CurlClientResponse.php @@ -35,6 +35,7 @@ class CurlClientResponse const STATUS_NO_CONTENT = 204; const STATUS_RESET_CONTENT = 205; const STATUS_PARTIAL_CONTENT = 206; + const STATUS_CONTINUE = 100; /** * Constructs a new object from an existing HTTP response. @@ -118,7 +119,8 @@ public function getValidStatusCodes() self::STATUS_NO_CONTENT, self::STATUS_RESET_CONTENT, self::STATUS_PARTIAL_CONTENT, - self::STATUS_CREATED + self::STATUS_CREATED, + self::STATUS_CONTINUE ); }