Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Makarov <[email protected]>
  • Loading branch information
Tigrov and samdark authored Jul 1, 2024
1 parent 4b9ed55 commit a9a82c8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
- Chg #846: Remove `SchemaInterface::isReadQuery()` and `AbstractSchema::isReadQuery()` methods (@Tigrov)
- Chg #847: Remove `SchemaInterface::getRawTableName()` and `AbstractSchema::getRawTableName()` methods (@Tigrov)
- Enh #852: Add method chaining for column classes (@Tigrov)
- Enh #855: Add array and json overlaps conditions (@Tigrov)
- Enh #855: Add array and JSON overlaps conditions (@Tigrov)

## 1.3.0 March 21, 2024

Expand Down
12 changes: 6 additions & 6 deletions docs/guide/en/query/where.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,22 @@ $query->where(['=', $column, $value]);

Requires two operands:

- Operator 1 should be a column name of an array type or DB expression representing an array;
- Operator 2 should be an array, iterator or DB expression representing an array.
- Operator 1 should be a column name of an array type or DB expression returning an array;
- Operator 2 should be an array, iterator or DB expression returning an array.

Checks if the first array contains at least one element from the second array. Currently supported only by PostgreSQL
and equals to `&&` operator.

For example, `['array overlaps', 'ids', [1, 2, 3]]` will generate `"ids"::text[] && ARRAY[1,2,3]::text[]`.

### json overlaps
### JSON overlaps

Requires two operands:

- Operator 1 should be a column name of a json type or DB expression representing a json;
- Operator 2 should be an array, iterator or DB expression representing an array.
- Operator 1 should be a column name of a JSON type or DB expression returning a JSON;
- Operator 2 should be an array, iterator or DB expression returning an array.

Checks if the json contains at least one element from the array. Currently supported only by PostgreSQL, MySQL and
Checks if the JSON contains at least one element from the array. Currently supported only by PostgreSQL, MySQL and
SQLite.

## Object format
Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/Condition/AbstractOverlapsCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getValues(): iterable|ExpressionInterface
public static function fromArrayDefinition(string $operator, array $operands): static

Check warning on line 40 in src/QueryBuilder/Condition/AbstractOverlapsCondition.php

View check run for this annotation

Codecov / codecov/patch

src/QueryBuilder/Condition/AbstractOverlapsCondition.php#L40

Added line #L40 was not covered by tests
{
if (!isset($operands[0], $operands[1])) {
throw new InvalidArgumentException("Operator \"$operator\" requires three operands.");
throw new InvalidArgumentException("Operator \"$operator\" requires two operands.");

Check warning on line 43 in src/QueryBuilder/Condition/AbstractOverlapsCondition.php

View check run for this annotation

Codecov / codecov/patch

src/QueryBuilder/Condition/AbstractOverlapsCondition.php#L42-L43

Added lines #L42 - L43 were not covered by tests
}

/** @psalm-suppress UnsafeInstantiation */
Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/Condition/JsonOverlapsCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Yiisoft\Db\QueryBuilder\Condition;

/**
* Condition that represents `JSON OVERLAPS` operator and is used to check if a column of json type overlaps an array.
* Condition that represents `JSON OVERLAPS` operator and is used to check if a column of JSON type overlaps an array.
*/
final class JsonOverlapsCondition extends AbstractOverlapsCondition
{
Expand Down

0 comments on commit a9a82c8

Please sign in to comment.