classNullIf
final class NullIf
implements Scalar, OutputNaming
uses Snapshot
@visibility public.NULLIF (value, other): NULL when the two are equal, otherwise the first.
Mirrors PostgreSQL's A_Expr of kind AEXPR_NULLIF over the = operator. Rule: PG-NULLIF-001. Facts: the = comparison of the operands must resolve (the operator table of Rules\Expression\Typing\OperatorTyping); the result has the type of the first operand, or of the second when the first is a string constant or NULL, which the implied = promotes; it may be NULL. A comparison that depends on a declaration, or is invalid, gives the call the same fact. The result column is named nullif. Source: https://www.postgresql.org/docs/17/functions-conditional.html#FUNCTIONS-NULLIF. Status: Implemented.
(new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Conditional\NullIf(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral(), new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()))->outputName()->value // => 'nullif'Properties§
public Scalar $valuepublic Scalar $otherMethods§
public function __construct(public Scalar $value, public Scalar $other)Parameters
$value | Scalar | The value returned when the two differ |
$other | Scalar | The value compared with |
public function outputName(): NameNames an unaliased result column.
Returns
Test cases 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operands, the comparison and the result.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 11
- method-call Derivation::scalar() line 62
- method-call OperatorTyping::named() line 64
- new OperatorTyping line 64
- new ScalarFact line 66
- class-const Nullability::Dependent() line 66
- new Categories line 68
- method-call Categories::builtin() line 69
- class-const Builtin::Unknown() line 69
- class-const Nullability::Nullable() line 70
- new Known line 73
- class-const Builtin::Text() line 73
public function render(Output $out): voidWrites NULLIF with the two operands.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::keyword() line 81
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.