classInTable
final class InTable
implements Scalar
uses Snapshot
@visibility public.A membership test against the rows of a named table or of a table-valued function, optionally negated.
Rule: SQLITE-IN-TABLE-001. x IN t reads every row of the relation t and x IN f(args) every row of a table-valued function. The use of the relation is recorded as a table use of the operation; without arguments its shape follows SQLITE-TABLE-SHAPE-001, with arguments SQLITE-TABLE-CALL-001. The result is INTEGER; it can be NULL when the operand or a compared column can be, and depends on the missing inputs when the shape of the relation is open. The relation has as many columns as the operand has values (SQLITE-ROW-VALUE-USE-001). The operand may not end in an operator weaker than the equality group (SQLITE-PRECEDENCE-001). Source: https://sqlite.org/lang_expr.html#the_in_and_not_in_operators. Status: Implemented.
$semantics = new \SqlSemantics\Platform\Sqlite\Semantics();
$table = $semantics->analyze('CREATE TABLE t (a INTEGER NOT NULL)');
$query = $semantics->analyze('SELECT 1 IN t', [$table]);
[$query->statement->columns[0]->expression->table->name->value, $query->facts->relation($query->statement->columns[0]->expression)->table->table === $table->declarations()[0], $query->field(0)->nullability] // => ['t', true, \SqlSemantics\Platform\Sqlite\Model\Statement\Type\Nullability::NotNull]Properties§
public list<Scalar>|null $argumentspublic Scalar $operandpublic QualifiedName $tablepublic bool $negated = falseMethods§
public function __construct(
public Scalar $operand,
public QualifiedName $table,
list<Scalar>|null $arguments = null,
public bool $negated = false,
)Parameters
$operand | Scalar | The tested expression |
$table | QualifiedName | The relation or function name |
$arguments | list<Scalar>|null | The arguments of a table-valued function; null when no argument list is written |
$negated | bool | Whether NOT is written before IN |
Calls 6
- static-call Check::listOf() line 67
- class-const Scalar::class() line 67
- static-call Check::input() line 68
- method-call Precedence::closing() line 68
- new Precedence line 68
- class-const Precedence::EQUALITY() line 68
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operand, the arguments, the use of the relation and the result.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 15
- method-call Derivation::scalar() line 76
- method-call Derivation::table() line 81
- method-call TableShapes::fact() line 83
- new TableShapes line 83
- new RelationFact line 84
- new RowShape line 84
- new UndeclaredRoutine line 84
- method-call Derivation::target() line 85
- method-call RowValueUse::membership() line 87
- new RowValueUse line 87
- function-call
countline 87 - class-const Nullability::Dependent() line 89
- new ScalarFact line 95
- new Known line 95
- class-const Storage::Integer() line 95
public function render(Output $out): voidWrites the test.
Parameters
$out | Output |
Calls 6
- method-call Output::node() line 103
- method-call Output::keyword() line 105
- method-call Output::name() line 109
- class-const NameUse::Qualifier() line 109
- class-const NameUse::Relation() line 111
- method-call Output::glue() line 113
Test cases 11§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
InTableTest::testDeriveScalarDependsOnAnUndeclaredTablecallsInTableTest::testDeriveScalarDependsOnTheRoutineOfATableValuedFunctioncallsInTableTest::testDeriveScalarReadsACommonTablecallsInTableTest::testDeriveScalarReadsADeclaredTableAndIsNotNullWhenNothingCanBeNullcallsInTableTest::testDeriveScalarReportsAMissingTableInACompleteContextcallsInTableTest::testRefusesAnOperandThatEndsInAWeakerOperatorcallsInTableTest::testRenderWritesANewlyBuiltTestcallsInTableTest::testRenderWritesTheNegationTheSchemaAndTheArgumentscalls
Relations§
Instantiated in 1
Type checks 3
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\Limits::classify() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/Limits.php:120
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\Limits::nonConstant() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/Limits.php:165
- instanceof SqlSemantics\Platform\Sqlite\Rules\Expression\Precedence::edges() packages/sql-semantics-sqlite/src/Rules/Expression/Precedence.php:127