final class NullIf
    implements Scalar, OutputNaming
    uses Snapshot
Public API: explicitly declared with @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.

Naming the result columndoctest
(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 $value
public Scalar $other

Methods§

public function __construct(public Scalar $value, public Scalar $other)

Parameters

$valueScalarThe value returned when the two differ
$otherScalarThe value compared with
public function outputName(): Name

Names an unaliased result column.

Returns

Test cases 1
Calls 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operands, the comparison and the result.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 11
public function render(Output $out): void

Writes NULLIF with the two operands.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 4§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4

Relations§

Instantiated in 1