diff --git a/docs/compatibility-list.md b/docs/compatibility-list.md index 3a23156..1ea57d7 100644 --- a/docs/compatibility-list.md +++ b/docs/compatibility-list.md @@ -74,7 +74,8 @@ rightJoin / rightJoinSub / joinWhere? where / orWhere / whereNot / orWhereNot / whereColumn / whereExists whereBetween / whereNotBetween / whereBetweenColumns / whereNotBetweenColumns / whereJsonContains / whereJsonLength / -whereIn / whereNotIn / whereNot / orWhereNot / whereNull / whereNotNull / +whereIn / whereNotIn / whereNone / orWhereNone / whereNot / orWhereNot / +whereNull / whereNotNull / whereDate / whereMonth / whereDay / whereYear / whereTime / whereRaw (use AQL) / whereAll / orWhereAll / whereAny / orWhereAny diff --git a/tests/Query/WheresTest.php b/tests/Query/WheresTest.php index 317311f..f3e244e 100644 --- a/tests/Query/WheresTest.php +++ b/tests/Query/WheresTest.php @@ -531,6 +531,49 @@ expect(($results->first())->name)->toBe('Stark'); }); +test('whereNone', function () { + $query = \DB::table('houses') + ->whereNone(['en.coat-of-arms', 'en.description'], 'LIKE', '%war%'); + + $binds = $query->getBindings(); + $bindKeys = array_keys($binds); + + $this->assertSame( + 'FOR houseDoc IN houses FILTER not ( `houseDoc`.`en`.`coat-of-arms` LIKE @' . $bindKeys[0] + . ' or `houseDoc`.`en`.`description` LIKE @' . $bindKeys[1] + . ') RETURN houseDoc', + $query->toSql(), + ); + + $results = $query->get(); + expect($results->count())->toBe(1); + expect(($results->first())->name)->toBe('Targaryen'); +}); + +test('orWhereNone', function () { + $query = \DB::table('houses') + ->where('name', 'Stark') + ->orWhereNone(['en.coat-of-arms', 'en.description'], 'LIKE', '%war%'); + + $binds = $query->getBindings(); + $bindKeys = array_keys($binds); + + $this->assertSame( + 'FOR houseDoc IN houses FILTER `houseDoc`.`name` == @' . $bindKeys[0] + + . ' or not ( `houseDoc`.`en`.`coat-of-arms` LIKE @' . $bindKeys[1] + . ' or `houseDoc`.`en`.`description` LIKE @' . $bindKeys[2] + . ') RETURN houseDoc', + $query->toSql(), + ); + + $results = $query->get(); + expect($results->count())->toBe(2); + expect(($results->first())->name)->toBe('Stark'); +}); + + + test('basic whereNot', function () { $builder = getBuilder(); $builder->select('*')->from('characters')->where('surname', 'Lannister')->whereNot('alive', true);