classNegation
final class Negation
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.The negation of a condition: NOT a.
Mirrors PostgreSQL's BoolExpr node of kind NOT_EXPR.
Rule: PG-NEGATION-001. Facts: boolean; a non-boolean operand is reported; NULL when the operand is NULL. The operand must keep its place without parentheses (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-logical.html. Status: Implemented.
(new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT NOT 1 = 2')->field(0)->type->descriptor->name() // => 'boolean'Properties§
public Scalar $operandMethods§
public function __construct(public Scalar $operand)Parameters
$operand | Scalar | The negated condition |
Calls 4
- static-call Check::input() line 42
- method-call Precedence::after() line 42
- new Precedence line 42
- class-const Precedence::NOT() line 42
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the condition and checks that it is boolean.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 7
- method-call Derivation::scalar() line 50
- new OperandChecks line 51
- new ScalarFact line 53
- method-call OperandChecks::boolean() line 53
- new Known line 53
- class-const Builtin::Bool() line 53
- method-call OperandChecks::nullability() line 53
public function render(Output $out): voidWrites NOT and the condition.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::keyword() line 61
Test cases 17§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 14
PrecedenceTest::testAfterTellsWhetherAnOperandKeepsItsPlaceAfterATokencallsPrecedenceTest::testClosingIsTheWeakestRuleOnTheRightEdgecallsPrecedenceTest::testTakesEscapeFindsAnOpenPatternMatchOnTheRightEdgecallsPrecedenceTest::testTakesUniquenessFindsAnOpenJsonTestOnTheRightEdgecallsCollationTest::testRejectsAnOperandThatBindsWeakercallsPatternMatchTest::testAcceptsANegatedPatternBeforeTheEscapecallsPatternMatchTest::testRejectsAPatternThatWouldTakeTheEscapecallsBooleanTestTest::testRejectsANegationcallsDocumentTestTest::testRejectsANegationcallsJsonTestTest::testRejectsANegationcallsNormalizationTestTest::testRejectsANegationcallsNullTestTest::testRejectsANegationcallsInSubqueryTest::testRejectsANegatedValuecallsPositionTest::testRejectsAnOperandThatIsNotRestrictedcalls