Browse Source

Rename whereIn()/whereNotIn() to whereInArray()/whereNotInArray()

chinpei215 8 years ago
parent
commit
9a1e49ee13
2 changed files with 16 additions and 16 deletions
  1. 3 3
      src/Database/Query.php
  2. 13 13
      tests/TestCase/Database/QueryTest.php

+ 3 - 3
src/Database/Query.php

@@ -906,7 +906,7 @@ class Query implements ExpressionInterface, IteratorAggregate
      * @param array $options Options
      * @return $this
      */
-    public function whereIn($field, array $values, array $options = [])
+    public function whereInArray($field, array $values, array $options = [])
     {
         $options += [
             'types' => [],
@@ -933,7 +933,7 @@ class Query implements ExpressionInterface, IteratorAggregate
      * @param array $options Options
      * @return $this
      */
-    public function whereNotIn($field, array $values, array $options = [])
+    public function whereNotInArray($field, array $values, array $options = [])
     {
         $options += [
             'types' => [],
@@ -941,7 +941,7 @@ class Query implements ExpressionInterface, IteratorAggregate
         ];
 
         if ($options['allowEmpty'] && !$values) {
-            return $this->where('1=1');
+            return $this->where([$field . ' IS NOT' => null]);
         }
 
         return $this->where([$field . ' NOT IN' => $values], $options['types']);

+ 13 - 13
tests/TestCase/Database/QueryTest.php

@@ -1714,17 +1714,17 @@ class QueryTest extends TestCase
     }
 
     /**
-     * Tests whereIn() and its input types.
+     * Tests whereInArray() and its input types.
      *
      * @return void
      */
-    public function testWhereIn()
+    public function testWhereInArray()
     {
         $this->loadFixtures('Articles');
         $query = new Query($this->connection);
         $query->select(['id'])
             ->from('articles')
-            ->whereIn('id', [2, 3])
+            ->whereInArray('id', [2, 3])
             ->execute();
         $sql = $query->sql();
 
@@ -1739,17 +1739,17 @@ class QueryTest extends TestCase
     }
 
     /**
-     * Tests whereIn() and empty array input.
+     * Tests whereInArray() and empty array input.
      *
      * @return void
      */
-    public function testWhereInEmpty()
+    public function testWhereInArrayEmpty()
     {
         $this->loadFixtures('Articles');
         $query = new Query($this->connection);
         $query->select(['id'])
             ->from('articles')
-            ->whereIn('id', [], ['allowEmpty' => true])
+            ->whereInArray('id', [], ['allowEmpty' => true])
             ->execute();
         $sql = $query->sql();
 
@@ -1764,17 +1764,17 @@ class QueryTest extends TestCase
     }
 
     /**
-     * Tests whereNotIn() and its input types.
+     * Tests whereNotInArray() and its input types.
      *
      * @return void
      */
-    public function testWhereNotIn()
+    public function testWhereNotInArray()
     {
         $this->loadFixtures('Articles');
         $query = new Query($this->connection);
         $query->select(['id'])
             ->from('articles')
-            ->whereNotIn('id', [1, 3])
+            ->whereNotInArray('id', [1, 3])
             ->execute();
         $sql = $query->sql();
 
@@ -1789,17 +1789,17 @@ class QueryTest extends TestCase
     }
 
     /**
-     * Tests whereNotIn() and empty array input.
+     * Tests whereNotInArray() and empty array input.
      *
      * @return void
      */
-    public function testWhereNotInEmpty()
+    public function testWhereNotInArrayEmpty()
     {
         $this->loadFixtures('Articles');
         $query = new Query($this->connection);
         $query->select(['id'])
             ->from('articles')
-            ->whereNotIn('id', [], ['allowEmpty' => true])
+            ->whereNotInArray('id', [], ['allowEmpty' => true])
             ->execute();
         $sql = $query->sql();
 
@@ -1807,7 +1807,7 @@ class QueryTest extends TestCase
         $this->assertEquals(['id' => '1'], $result->fetch('assoc'));
 
         $this->assertQuotedQuery(
-            'SELECT <id> FROM <articles> WHERE 1=1',
+            'SELECT <id> FROM <articles> WHERE \(<id>\) IS NOT NULL',
             $sql,
             !$this->autoQuote
         );