classPositions
final class Positions
Tells which ORDER BY, GROUP BY and DISTINCT ON terms PostgreSQL reads as output column positions.
Rule: PG-OUTPUT-POSITION-001. PostgreSQL decides this from the parse tree before resolving anything. A term that is a plain constant is a position when it is an integer of type integer and an error otherwise; parentheses around the constant are not kept by the server, and a minus sign written before it is folded into it. Every other term is an expression. Source: https://www.postgresql.org/docs/17/sql-select.html#SQL-ORDERBY, https://www.postgresql.org/docs/17/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS-NUMERIC. Status: Implemented.
Methods§
public function value(Scalar $term): ?stringAnswers the position a term denotes as an exact decimal integer, or null when the term is not an integer constant.
Parameters
$term | Scalar |
Returns
?stringTest cases 1
Called from 9
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::positioned() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:82
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Positions::misused() packages/sql-semantics-postgres/src/Rules/Query/Positions.php:59
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\OutputPosition::__construct() packages/sql-semantics-postgres/src/Statement/Query/Clause/OutputPosition.php:51
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\OutputPosition::value() packages/sql-semantics-postgres/src/Statement/Query/Clause/OutputPosition.php:59
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\SelectOptions::__construct() packages/sql-semantics-postgres/src/Statement/Query/Clause/SelectOptions.php:61
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Grouping\GroupingRow::__construct() packages/sql-semantics-postgres/src/Statement/Query/Grouping/GroupingRow.php:51
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Grouping\GroupingSet::__construct() packages/sql-semantics-postgres/src/Statement/Query/Grouping/GroupingSet.php:49
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Select::__construct() packages/sql-semantics-postgres/src/Statement/Query/Select.php:96
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Select::__construct() packages/sql-semantics-postgres/src/Statement/Query/Select.php:102
Calls 2
- method-call Positions::minus() line 39
- class-const Builtin::Int4() line 43
public function misused(Scalar $term): boolTells whether a term is a constant that is not an integer, which PostgreSQL rejects in these clauses.
Parameters
$term | Scalar |
Returns
boolTest cases 1
Called from 2
Calls 2
- method-call Positions::minus() line 56
- method-call Positions::value() line 59
public function minus(UnaryOperation $operation): boolTells whether an operation is the plain minus sign the server folds into a numeric constant.
Parameters
$operation | UnaryOperation |
Returns
boolTest cases 1
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 10
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::positioned() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:82
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering::outputs() packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:108
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering::term() packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:129
- new SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\OutputPosition::__construct() packages/sql-semantics-postgres/src/Statement/Query/Clause/OutputPosition.php:51
- new SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\OutputPosition::value() packages/sql-semantics-postgres/src/Statement/Query/Clause/OutputPosition.php:59
- new SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\SelectOptions::__construct() packages/sql-semantics-postgres/src/Statement/Query/Clause/SelectOptions.php:61
- new SqlSemantics\Platform\PostgreSql\Statement\Query\Grouping\GroupingRow::__construct() packages/sql-semantics-postgres/src/Statement/Query/Grouping/GroupingRow.php:51
- new SqlSemantics\Platform\PostgreSql\Statement\Query\Grouping\GroupingSet::__construct() packages/sql-semantics-postgres/src/Statement/Query/Grouping/GroupingSet.php:49
- new SqlSemantics\Platform\PostgreSql\Statement\Query\Select::__construct() packages/sql-semantics-postgres/src/Statement/Query/Select.php:96
- new SqlSemantics\Platform\PostgreSql\Statement\Query\Select::__construct() packages/sql-semantics-postgres/src/Statement/Query/Select.php:102
Method calls 10
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::positioned() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:82
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering::outputs() packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:108
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering::term() packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:129
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\OutputPosition::__construct() packages/sql-semantics-postgres/src/Statement/Query/Clause/OutputPosition.php:51
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\OutputPosition::value() packages/sql-semantics-postgres/src/Statement/Query/Clause/OutputPosition.php:59
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\SelectOptions::__construct() packages/sql-semantics-postgres/src/Statement/Query/Clause/SelectOptions.php:61
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Grouping\GroupingRow::__construct() packages/sql-semantics-postgres/src/Statement/Query/Grouping/GroupingRow.php:51
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Grouping\GroupingSet::__construct() packages/sql-semantics-postgres/src/Statement/Query/Grouping/GroupingSet.php:49
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Select::__construct() packages/sql-semantics-postgres/src/Statement/Query/Select.php:96
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Select::__construct() packages/sql-semantics-postgres/src/Statement/Query/Select.php:102