classRowValueUse
final class RowValueUse
Reports the places where a row value is used as a single value, or where two row widths disagree.
Rule: SQLITE-ROW-VALUE-USE-001. A row value is admitted only where SQLite compares rows: on both sides of a comparison or IS operator, in BETWEEN when the bounds are rows of the same width, as the operand of IN against elements, rows or a relation of the same width, and as the base of a CASE with WHEN values of the same width. Anywhere else a row value is misused: as an operand of any other operator, as a condition, a grouping or ordering term, or a result column. The width of a value whose type depends on missing inputs is unknown and nothing is reported for it. Terminates: a fixed number of tests per use. Source: https://sqlite.org/rowvalue.html. Status: Implemented.
Methods§
public function width(ScalarFact $fact): ?intAnswers the number of values a fact stands for: 1 for a single value, the row width for a row value, null when unknown.
Parameters
$fact | ScalarFact |
Returns
?intTest cases 2
Called from 5
- method-call SqlSemantics\Platform\Sqlite\Rules\Expression\RowValueUse::single() packages/sql-semantics-sqlite/src/Rules/Expression/RowValueUse.php:53
- method-call SqlSemantics\Platform\Sqlite\Rules\Expression\RowValueUse::uniform() packages/sql-semantics-sqlite/src/Rules/Expression/RowValueUse.php:71
- method-call SqlSemantics\Platform\Sqlite\Rules\Expression\RowValueUse::membership() packages/sql-semantics-sqlite/src/Rules/Expression/RowValueUse.php:87
- method-call SqlSemantics\Platform\Sqlite\Rules\Expression\RowValueUse::elements() packages/sql-semantics-sqlite/src/Rules/Expression/RowValueUse.php:100
- method-call SqlSemantics\Platform\Sqlite\Rules\Expression\RowValueUse::elements() packages/sql-semantics-sqlite/src/Rules/Expression/RowValueUse.php:102
public function single(ScalarFact $fact, Derivation $derivation): ?MisuseReports a row value at a position that takes a single value, and answers the reported problem.
Parameters
$fact | ScalarFact | |
$derivation | Derivation |
Returns
Test cases 2
Called from 14
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:57
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:61
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\SortScopes::derive() packages/sql-semantics-sqlite/src/Rules/Query/SortScopes.php:63
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::enter() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:93
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\CaseExpression::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/CaseExpression.php:66
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\CaseExpression::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/CaseExpression.php:68
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\CaseExpression::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/CaseExpression.php:74
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Collate::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Collate.php:58
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:67
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:68
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:81
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:82
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:87
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:55
Calls 4
- method-call RowValueUse::width() line 53
- new Misuse line 56
- class-const MisuseRule::TooManyValueColumns() line 56
- method-call Derivation::report() line 57
public function uniform(list<ScalarFact> $facts, Derivation $derivation): voidReports values compared with each other whose known widths disagree.
Parameters
$facts | list<ScalarFact> | |
$derivation | Derivation |
Test cases 3
Called from 3
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\CaseExpression::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/CaseExpression.php:66
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:65
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:65
Calls 8
- method-call RowValueUse::width() line 71
- function-call
in_arrayline 72 - function-call
countline 76 - method-call Derivation::report() line 79
- new Misuse line 79
- class-const MisuseRule::TooManyValueColumns() line 79
- new ArityMismatch line 79
- class-const ArityRule::RowComparison() line 79
public function membership(ScalarFact $operand, int $columns, Derivation $derivation): voidReports an IN operand whose width differs from the number of columns of the rows it is compared with.
Parameters
$operand | ScalarFact | |
$columns | int | |
$derivation | Derivation |
Test cases 2
Called from 2
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InQuery::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InQuery.php:61
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InTable::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InTable.php:87
Calls 4
- method-call RowValueUse::width() line 87
- method-call Derivation::report() line 89
- new ArityMismatch line 89
- class-const ArityRule::ScalarSubquery() line 89
public function elements(
ScalarFact $operand,
list<ScalarFact> $elements,
Derivation $derivation,
): voidReports the first element of an IN list whose known width differs from that of the operand.
Parameters
$operand | ScalarFact | |
$elements | list<ScalarFact> | |
$derivation | Derivation |
Test cases 3
Called from 1
Calls 4
- method-call RowValueUse::width() line 100
- method-call Derivation::report() line 104
- new ArityMismatch line 104
- class-const ArityRule::InListElement() line 104
Test cases 12§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 12
RowValueUseTest::testElementsReportsNothingForMatchingOrUnknownWidthscallsRowValueUseTest::testElementsReportsTheFirstElementOfAnotherWidthOnlycallsRowValueUseTest::testElementsSpellsTheTermsOfARowElementInThePluralcallsRowValueUseTest::testMembershipReportsAnOperandOfAnotherWidthThanTheColumnscallsRowValueUseTest::testMembershipReportsNothingForAMatchingOrUnknownWidthcallsRowValueUseTest::testSingleAdmitsASingleValueAndAnUnknownWidthcallsRowValueUseTest::testSingleReportsARowValueAndAnswersTheProblemcallsRowValueUseTest::testUniformReportsARowValueBesideASingleValuecallsRowValueUseTest::testUniformReportsNothingForEqualOrUnknownWidthscallsRowValueUseTest::testUniformReportsRowsOfDifferentWidthscallsRowValueUseTest::testWidthIsOneForASingleValueAndTheWidthOfARowValuecallsRowValueUseTest::testWidthIsUnknownForADependentOrInvalidTypecalls
Relations§
Instantiated in 12
- new SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:55
- new SqlSemantics\Platform\Sqlite\Rules\Query\SortScopes::derive() packages/sql-semantics-sqlite/src/Rules/Query/SortScopes.php:63
- new SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::enter() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:93
- new SqlSemantics\Platform\Sqlite\Statement\Expression\CaseExpression::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/CaseExpression.php:60
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Collate::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Collate.php:58
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:65
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:63
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:80
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:55
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InList::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InList.php:71
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InQuery::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InQuery.php:61
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InTable::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InTable.php:87
Method calls 20
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:57
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:61
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\SortScopes::derive() packages/sql-semantics-sqlite/src/Rules/Query/SortScopes.php:63
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::enter() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:93
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\CaseExpression::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/CaseExpression.php:66
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\CaseExpression::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/CaseExpression.php:66
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\CaseExpression::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/CaseExpression.php:68
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\CaseExpression::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/CaseExpression.php:74
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Collate::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Collate.php:58
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:65
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:65
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:67
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:68
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:81
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:82
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:87
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:55
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InList::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InList.php:71
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InQuery::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InQuery.php:61
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InTable::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InTable.php:87