classMemberOf
final class MemberOf
implements Scalar
uses Snapshot
@visibility public.A JSON array membership test: value MEMBER OF (json_array) (Item_func_member_of, MySQL 8.0.17 and later).
The keyword OF is optional in the grammar and does not change the test; whether it is written is kept, since it is part of the text MySQL names an unaliased select list expression after. The value is a bit_expr and the array a simple_expr (MYSQL-PRECEDENCE-001).
Rule: MYSQL-MEMBER-OF-001. Facts: 1, 0 or NULL, an integer; it can be NULL when an operand can. Terminates: the operands are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/json-search-functions.html#operator_member-of. Status: Implemented.
(new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE 1 MEMBER (a)')->toString() // => 'SELECT a FROM t WHERE 1 MEMBER (a)'Properties§
public Scalar $operandpublic Scalar $arraypublic OptionalWords $of = OptionalWords::WrittenMethods§
public function __construct(
public Scalar $operand,
public Scalar $array,
public OptionalWords $of = OptionalWords::Written,
)Parameters
$operand | Scalar | The value searched for |
$array | Scalar | The JSON array searched |
$of | OptionalWords | Whether the optional OF is written |
Calls 8
- class-const OptionalWords::Written() line 45
- new Precedence line 47
- static-call Check::input() line 48
- method-call Precedence::fits() line 48
- class-const Precedence::PREDICATE() line 48
- class-const Precedence::BIT_EXPR() line 48
- method-call Precedence::admits() line 49
- class-const Precedence::SIMPLE_EXPR() line 49
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives both operands and combines their NULL facts; the test needs MySQL 8.0 or later.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 7
- static-call Check::input() line 58
- class-const GrammarRelease::MySql5651() line 58
- class-const GrammarRelease::MySql5744() line 58
- new Operands line 59
- method-call Operands::single() line 60
- method-call Derivation::scalar() line 60
- method-call Operands::truth() line 63
public function render(Output $out): voidWrites the value, MEMBER, OF when it is written, and the array in parentheses.
Parameters
$out | Output |
Test cases 1
Calls 4
- method-call Output::node() line 71
- class-const OptionalWords::Written() line 72
- method-call Output::keyword() line 73
- method-call Output::symbol() line 75
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.