classComparisonTyping
final class ComparisonTyping
Types the six comparison operators over catalog types.
Rule: PG-OPERATOR-COMPARISON-001 (slice — the expression family completes or replaces this with its operator table). Scope: =, <>, <, >, <=, >=, unqualified or qualified with pg_catalog. Operators are looked up by name and argument types, and a context declares no routines, so a result is known only when pg_catalog holds an operator for exactly the operand types and no schema searched before pg_catalog can supply another one: the result is then boolean. A string constant or NULL operand takes the type of the other operand; two such operands compare as text. Every other combination depends on the operator's declaration. An invalid operand makes the comparison invalid; a dependent operand makes it depend on the same inputs. Minimum precision: Known(boolean) for the exact catalog pairs listed here. Source: https://www.postgresql.org/docs/17/typeconv-oper.html, https://www.postgresql.org/docs/17/functions-comparison.html. Termination: constant work. Status: Specified.
Constants§
public const OPERATORS = ['=', '<>', '<', '>', '<=', '>=']The comparison operator names.
Methods§
public function result(
AnalysisContext $context,
OperatorName $operator,
TypeFact $left,
TypeFact $right,
): TypeFactAnswers the type of a comparison of two operands.
Parameters
$context | AnalysisContext | |
$operator | OperatorName | |
$left | TypeFact | |
$right | TypeFact |
Returns
Test cases 3
Calls 10
- method-call ComparisonTyping::base() line 71
- method-call ComparisonTyping::catalog() line 73
- new Dependent line 74
- new UndeclaredRoutine line 74
- new QualifiedName line 74
- class-const Builtin::Unknown() line 76
- class-const Builtin::Text() line 76
- method-call ComparisonTyping::exact() line 79
- new Known line 79
- class-const Builtin::Bool() line 79
Answers the catalog type an operand contributes to the lookup: unknown for a string constant or NULL, null for a type this table does not cover.
Parameters
$operand | TypeFact |
Returns
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\ComparisonTyping::result() packages/sql-semantics-postgres/src/Rules/Expression/ComparisonTyping.php:71
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\ComparisonTyping::result() packages/sql-semantics-postgres/src/Rules/Expression/ComparisonTyping.php:72
Calls 2
- class-const Builtin::Unknown() line 88
- class-const Builtin::Interval() line 97
public function catalog(AnalysisContext $context, OperatorName $operator): boolTells whether the operator name is a comparison looked up in pg_catalog before any other schema.
Parameters
$context | AnalysisContext | |
$operator | OperatorName |
Returns
boolTest cases 1
Called from 1
Calls 3
- function-call
in_arrayline 108 - class-const ComparisonTyping::OPERATORS() line 108
- function-call
countline 112
Tells whether pg_catalog holds the six comparison operators for exactly a pair of types.
Returns
boolTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\ComparisonTyping::result() packages/sql-semantics-postgres/src/Rules/Expression/ComparisonTyping.php:79
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\OperatorTyping::comparable() packages/sql-semantics-postgres/src/Rules/Expression/Typing/OperatorTyping.php:200
Calls 3
- function-call
in_arrayline 129 - class-const ComparisonTyping::SAME() line 129
- class-const ComparisonTyping::CROSS() line 131
Private surface 2§
Implementation details, listed for orientation only.
private const SAME = ['bool', 'bytea', 'char', 'name', 'int2', 'int4', 'int8', 'text', 'oid', 'tid',…private const CROSS = [['int2', 'int4', 'int8'], ['float4', 'float8'], ['date', 'timestamp', 'timesta…Test cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
ComparisonTypingTest::testBaseReadsTheCatalogTypeOfAnOperandcallsComparisonTypingTest::testCatalogRequiresTheCatalogToBeSearchedFirstcallsComparisonTypingTest::testExactListsThePairsTheCatalogComparescallsComparisonTypingTest::testResultDependsOnTheOperatorWhenTheCatalogHasNoExactOnecallsComparisonTypingTest::testResultIsBooleanForAnExactCatalogOperatorcallsComparisonTypingTest::testResultPassesOnAnOperandThatIsNotKnowncalls