classSortTerm
final class SortTerm
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.One ordering term: an expression with its optional direction and NULL placement.
The same term form orders query results, window partitions and aggregate arguments, and lists the columns of an index or of a conflict target.
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT a FROM t ORDER BY a + 1 ASC NULLS FIRST');
$term = $query->statement->orderBy[0];
[$term->direction, $term->nulls] // => [\SqlSemantics\Platform\Sqlite\Statement\Query\Ordering\SortDirection::Ascending, \SqlSemantics\Platform\Sqlite\Statement\Query\Ordering\NullsOrder::First]Properties§
public Scalar $expressionpublic SortDirection|null $direction = nullpublic NullsOrder|null $nulls = nullMethods§
public function __construct(
public Scalar $expression,
public SortDirection|null $direction = null,
public NullsOrder|null $nulls = null,
)Parameters
$expression | Scalar | The ordering expression |
$direction | SortDirection|null | The written direction |
$nulls | NullsOrder|null | The written NULL placement |
public function render(Output $out): voidWrites the expression, the direction and the NULL placement.
Parameters
$out | Output |
Calls 2
- method-call Output::node() line 42
- method-call Output::keyword() line 44
Test cases 15§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Other tests reaching this symbol 14
KeyTermRuleTest::testTermLeavesEveryOtherTermAsItIscallsSortRuleTest::testDirectionLowersAscDescOrNonecallsSortRuleTest::testNullsLowersFirstLastOrNonecallsSortRuleTest::testTermsLowersEachTermWithItsDirectionAndNullPlacementcallsInsertFactsTest::testDeriveLetsUpsertsSeeTheTargetAndExcludedInTheRightPlacescallsWindowSpecTest::testRenderWritesANewlyBuiltSpecificationcallsInsertRowsTest::testRejectsANonLastUpsertWithoutAConflictTargetcallsInsertSelectTest::testRejectsANonLastUpsertWithoutAConflictTargetcallsCompoundTest::testRenderRefusesAnIntegerConstantAsAnOrdinaryOrderByTermcallsSelectTest::testRenderRefusesAnIntegerConstantAsAnOrdinaryOrderByTermcallsSelectTest::testRenderWritesANewlyBuiltSelectioncallsCreateIndexTest::testRefusesAStringLiteralTermThatNamesAColumncallsTablePrimaryKeyTest::testRefusesAStringLiteralTermThatNamesAColumncallsTableUniqueTest::testRefusesAStringLiteralTermThatNamesAColumncalls
Relations§
Instantiated in 2
Constant reads 8
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\FunctionCall::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/FunctionCall.php:80
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Window\WindowSpec::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Window/WindowSpec.php:50
- class-const SqlSemantics\Platform\Sqlite\Statement\Mutation\ConflictTarget::__construct() packages/sql-semantics-sqlite/src/Statement/Mutation/ConflictTarget.php:39
- class-const SqlSemantics\Platform\Sqlite\Statement\Query\Compound::__construct() packages/sql-semantics-sqlite/src/Statement/Query/Compound.php:64
- class-const SqlSemantics\Platform\Sqlite\Statement\Query\Select::__construct() packages/sql-semantics-sqlite/src/Statement/Query/Select.php:92
- class-const SqlSemantics\Platform\Sqlite\Statement\Schema\CreateIndex::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/CreateIndex.php:84
- class-const SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TablePrimaryKey::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TablePrimaryKey.php:56
- class-const SqlSemantics\Platform\Sqlite\Statement\Schema\Table\TableUnique::__construct() packages/sql-semantics-sqlite/src/Statement/Schema/Table/TableUnique.php:51
Type declarations 6
- type SqlSemantics\Platform\Sqlite\Lowering\Definition\KeyTermRule::keyTerms() packages/sql-semantics-sqlite/src/Lowering/Definition/KeyTermRule.php:42
- type SqlSemantics\Platform\Sqlite\Lowering\Definition\KeyTermRule::indexTerms() packages/sql-semantics-sqlite/src/Lowering/Definition/KeyTermRule.php:53
- type SqlSemantics\Platform\Sqlite\Lowering\Definition\KeyTermRule packages/sql-semantics-sqlite/src/Lowering/Definition/KeyTermRule.php:61
- type SqlSemantics\Platform\Sqlite\Rules\Query\CompoundFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/CompoundFacts.php:85
- type SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:48
- type SqlSemantics\Platform\Sqlite\Statement\Query\Select::__construct() packages/sql-semantics-sqlite/src/Statement/Query/Select.php:94