classInList
final class InList
implements Scalar
uses Snapshot
@visibility public.A membership test in a list of expressions: x [NOT] IN (e1, e2 …) (Item_func_in).
A list of one element is kept as written; the server evaluates it as the equality (or inequality) with that element, which has the same facts. The operand is a bit_expr (MYSQL-PRECEDENCE-001).
Rule: MYSQL-IN-LIST-001. Facts: 1, 0 or NULL, an integer; it can be NULL when the operand or an element can. The operand and every element must have the same number of columns (MYSQL-OPERAND-COLUMNS-001). Terminates: the operand and the elements are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/comparison-operators.html#operator_in. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a NOT IN (1, 2)');
[$query->statement->where->negated, count($query->statement->where->elements)] // => [true, 2]Properties§
public non-empty-list<Scalar> $elementspublic Scalar $operandpublic bool $negated = falseMethods§
public function __construct(
public Scalar $operand,
list<Scalar> $elements,
public bool $negated = false,
)Parameters
$operand | Scalar | The tested expression |
$elements | list<Scalar> | The elements in order; at least one |
$negated | bool | Whether NOT is written before IN |
Calls 7
- static-call Check::input() line 52
- method-call Precedence::fits() line 52
- new Precedence line 52
- class-const Precedence::PREDICATE() line 52
- class-const Precedence::BIT_EXPR() line 52
- static-call Check::listOf() line 53
- class-const Scalar::class() line 53
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operand and the elements, checks their widths and combines their NULL facts.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- method-call Derivation::scalar() line 61
- new Operands line 69
- method-call Operands::comparable() line 70
- method-call Operands::truth() line 72
public function render(Output $out): voidWrites the operand, the optional NOT, IN and the elements in parentheses.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::node() line 80
- method-call Output::keyword() line 82
Test cases 11§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
Other tests reaching this symbol 6
PredicateRuleTest::testOperationLowersTheListAndSubqueryFormsOfIncallsPrecedenceTest::testLeadingAnswersTheExpressionWrittenFirstcallsPrecedenceTest::testOpeningIsTheWeakestLevelOnTheLeftEdgecallsPrecedenceTest::testPostfixAnswersTheEdgesOfAFormWrittenAfterItsOperandcallsFullTextSearchTest::testAPredicateSearchStringIsRejectedcallsRegexpTest::testAPredicatePatternIsRejectedcalls
Relations§
Instantiated in 2
- new SqlSemantics\Platform\MySql\Lowering\Expression\PredicateRule::operation() packages/sql-semantics-mysql/src/Lowering/Expression/PredicateRule.php:90
- new SqlSemantics\Platform\MySql\Lowering\Expression\PredicateRule::operation() packages/sql-semantics-mysql/src/Lowering/Expression/PredicateRule.php:91