classCollate
final class Collate
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.An expression with an explicit collating sequence for the comparisons it takes part in.
Rule: SQLITE-COLLATE-001. The operator changes no value: the type and the NULL fact are those of the operand, and the name resolution stays with the operand. The operand is a single value (SQLITE-ROW-VALUE-USE-001): a collated row value is invalid. The operand must bind at least as tightly as COLLATE (SQLITE-PRECEDENCE-001). Source: https://sqlite.org/lang_expr.html#collate_operator, https://sqlite.org/datatype3.html#collation. Status: Implemented.
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT a COLLATE NOCASE FROM t');
$query->statement->columns[0]->expression->collation->value // => 'NOCASE'$sum = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1 + 2')->statement->columns[0]->expression;
new \SqlSemantics\Platform\Sqlite\Statement\Expression\Collate($sum, new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('NOCASE')) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionProperties§
public Scalar $operandpublic Name $collationMethods§
public function __construct(public Scalar $operand, public Name $collation)Parameters
$operand | Scalar | The collated expression |
$collation | Name | The collating sequence name |
Calls 4
- static-call Check::input() line 49
- method-call Precedence::closing() line 49
- new Precedence line 49
- class-const Precedence::COLLATION() line 49
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operand; the collation changes no value.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 5
- method-call Derivation::scalar() line 57
- method-call RowValueUse::single() line 58
- new RowValueUse line 58
- new ScalarFact line 60
- new Invalid line 60
public function render(Output $out): voidWrites the operand and the collation.
Parameters
$out | Output |
Calls 2
- method-call Output::node() line 71
- class-const NameUse::Label() line 71
Test cases 24§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 20
KeyTermRuleTest::testExpressionRebuildsTheWrappersInOrderAroundTheLiteralcallsKeyTermRuleTest::testIndexTermsWrapAStringUnderAtMostOneCollationcallsKeyTermRuleTest::testKeyTermsWrapAStringUnderAnyParenthesesAndCollationscallsExpressionRuleTest::testExpressionLowersCollateCastAndRowExpressionscallsNameRuleTest::testCollationOfAnExpressionIsDecodedLikeAnyNamecallsUpsertRuleTest::testTailLowersTargetedDoUpdateAndDoNothingClausesInWrittenOrdercallsKeyTermsTest::testBeneathStopsAtTheCollationLimitcallsKeyTermsTest::testCoreLooksThroughParenthesesAndCollationscallsKeyTermsTest::testReferenceAcceptsEveryColumnReferenceAndNoOtherExpressioncallsKeyTermsTest::testStringTellsALiteralUnderTheAdmittedWrapperscallsPrecedenceTest::testEdgesOfAPostfixOperatorHaveNoRightOperandcallsOrdinalsTest::testValueLooksThroughSignsCollationsAndParenthesescallsResultNamesTest::testInnerLooksThroughParenthesesCollateAndTheLikelihoodFunctionscallsResultNamesTest::testRelationPrefersTheAliasThenTheWrittenWordThenTheTextcallsResultNamesTest::testWrittenAnswersTheOneWordAnExpressionConsistsOfcallsSortScopesTest::testWordAnswersAnUnqualifiedWordOnlycallsUnaryTest::testRenderCoversTheTighterOperatorsThatFollowThePrefixcallsOutputOrdinalTest::testPositionCountsFromOnecallsCreateIndexTest::testDeriveStatementResolvesTheTableAndTheIndexedColumnscallsTablePrimaryKeyTest::testRefusesAStringLiteralTermThatNamesAColumncalls
Relations§
Instantiated in 2
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\KeyTermRule::expression() packages/sql-semantics-sqlite/src/Lowering/Definition/KeyTermRule.php:82
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\ExpressionRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/ExpressionRule.php:72
Type checks 11
- instanceof SqlSemantics\Platform\Sqlite\Lowering\Definition\KeyTermRule::expression() packages/sql-semantics-sqlite/src/Lowering/Definition/KeyTermRule.php:76
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\KeyTerms::core() packages/sql-semantics-sqlite/src/Rules/Definition/KeyTerms.php:43
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\KeyTerms::beneath() packages/sql-semantics-sqlite/src/Rules/Definition/KeyTerms.php:55
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\KeyTerms::beneath() packages/sql-semantics-sqlite/src/Rules/Definition/KeyTerms.php:56
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ExpressionAffinity::of() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ExpressionAffinity.php:79
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ValueKinds::of() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ValueKinds.php:88
- instanceof SqlSemantics\Platform\Sqlite\Rules\Expression\Precedence::edges() packages/sql-semantics-sqlite/src/Rules/Expression/Precedence.php:118
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\Ordinals::value() packages/sql-semantics-sqlite/src/Rules/Query/Ordinals.php:35
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::written() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:148
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::inner() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:194
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\SortScopes::word() packages/sql-semantics-sqlite/src/Rules/Query/SortScopes.php:73