Skip to content

Commit 9e1b965

Browse files
Confirmed proper functioning of whereNone/orWhereNone (#168)
1 parent 5f36deb commit 9e1b965

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

docs/compatibility-list.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ rightJoin / rightJoinSub / joinWhere?
7474
where / orWhere / whereNot / orWhereNot / whereColumn / whereExists
7575
whereBetween / whereNotBetween / whereBetweenColumns / whereNotBetweenColumns /
7676
whereJsonContains / whereJsonLength /
77-
whereIn / whereNotIn / whereNot / orWhereNot / whereNull / whereNotNull /
77+
whereIn / whereNotIn / whereNone / orWhereNone / whereNot / orWhereNot /
78+
whereNull / whereNotNull /
7879
whereDate / whereMonth / whereDay / whereYear / whereTime /
7980
whereRaw (use AQL) /
8081
whereAll / orWhereAll / whereAny / orWhereAny

tests/Query/WheresTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,49 @@
531531
expect(($results->first())->name)->toBe('Stark');
532532
});
533533

534+
test('whereNone', function () {
535+
$query = \DB::table('houses')
536+
->whereNone(['en.coat-of-arms', 'en.description'], 'LIKE', '%war%');
537+
538+
$binds = $query->getBindings();
539+
$bindKeys = array_keys($binds);
540+
541+
$this->assertSame(
542+
'FOR houseDoc IN houses FILTER not ( `houseDoc`.`en`.`coat-of-arms` LIKE @' . $bindKeys[0]
543+
. ' or `houseDoc`.`en`.`description` LIKE @' . $bindKeys[1]
544+
. ') RETURN houseDoc',
545+
$query->toSql(),
546+
);
547+
548+
$results = $query->get();
549+
expect($results->count())->toBe(1);
550+
expect(($results->first())->name)->toBe('Targaryen');
551+
});
552+
553+
test('orWhereNone', function () {
554+
$query = \DB::table('houses')
555+
->where('name', 'Stark')
556+
->orWhereNone(['en.coat-of-arms', 'en.description'], 'LIKE', '%war%');
557+
558+
$binds = $query->getBindings();
559+
$bindKeys = array_keys($binds);
560+
561+
$this->assertSame(
562+
'FOR houseDoc IN houses FILTER `houseDoc`.`name` == @' . $bindKeys[0]
563+
564+
. ' or not ( `houseDoc`.`en`.`coat-of-arms` LIKE @' . $bindKeys[1]
565+
. ' or `houseDoc`.`en`.`description` LIKE @' . $bindKeys[2]
566+
. ') RETURN houseDoc',
567+
$query->toSql(),
568+
);
569+
570+
$results = $query->get();
571+
expect($results->count())->toBe(2);
572+
expect(($results->first())->name)->toBe('Stark');
573+
});
574+
575+
576+
534577
test('basic whereNot', function () {
535578
$builder = getBuilder();
536579
$builder->select('*')->from('characters')->where('surname', 'Lannister')->whereNot('alive', true);

0 commit comments

Comments
 (0)