Skip to content
Permalink
Browse files

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

  • Loading branch information...
chinpei215 committed Mar 15, 2018
1 parent 8f0cde7 commit 9a1e49ee13765506eb9f8cba02fa605a18ee25f2
Showing with 16 additions and 16 deletions.
  1. +3 −3 src/Database/Query.php
  2. +13 −13 tests/TestCase/Database/QueryTest.php
@@ -906,7 +906,7 @@ public function where($conditions = null, $types = [], $overwrite = false)
* @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,15 +933,15 @@ public function whereIn($field, array $values, array $options = [])
* @param array $options Options
* @return $this
*/
public function whereNotIn($field, array $values, array $options = [])
public function whereNotInArray($field, array $values, array $options = [])
{
$options += [
'types' => [],
'allowEmpty' => false,
];
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']);
@@ -1714,17 +1714,17 @@ public function testSelectWhereNot2()
}
/**
* 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 @@ public function testWhereIn()
}
/**
* 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 @@ public function testWhereInEmpty()
}
/**
* 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,25 +1789,25 @@ public function testWhereNotIn()
}
/**
* 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();
$result = $query->execute();
$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
);

0 comments on commit 9a1e49e

Please sign in to comment.
You can’t perform that action at this time.