final class PatternMatch
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A pattern match: a [NOT] LIKE p, ILIKE, SIMILAR TO, with an optional ESCAPE e.

Mirrors PostgreSQL's A_Expr node of kind AEXPR_LIKE, AEXPR_ILIKE or AEXPR_SIMILAR; an ESCAPE clause becomes a call of like_escape or similar_to_escape on the pattern.

Rule: PG-PATTERN-MATCH-001. Facts: the type of the matching operator over the operands (PG-OPERATOR-TYPING-001): boolean for string operands, and for bytea with LIKE; NULL when an operand can be. The value must keep its place before the keyword, the pattern after it, and the escape after ESCAPE; with ESCAPE, the pattern may not end in a match without one, which would take it (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-matching.html. Status: Implemented.

Reading a negated match with an escape characterdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SELECT 'a' NOT LIKE 'a!%' ESCAPE '!'");
    [$query->field(0)->expression->escape->value->value, $query->field(0)->type->descriptor->name()] // => ['!', 'boolean']

Properties§

public Scalar $left
public PatternOperator $operator
public bool $negated
public Scalar $right
public Scalar|null $escape = null

Methods§

public function __construct(
    public Scalar $left,
    public PatternOperator $operator,
    public bool $negated,
    public Scalar $right,
    public Scalar|null $escape = null,
)

Parameters

$leftScalarThe matched value
$operatorPatternOperatorThe matching keyword
$negatedboolWhether NOT is written
$rightScalarThe pattern
$escapeScalar|nullThe escape character, or null when ESCAPE is not written
Calls 6
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operands and the type of the match.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the value, the keyword, the pattern and the escape.

Parameters

$outOutput
Test cases 1
Calls 5

Test cases 8§

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

Dedicated tests 4
Other tests reaching this symbol 4

Relations§

Instantiated in 1
Type checks 2