classLike
final class Like
implements Scalar
uses Snapshot
@visibility public.A pattern match: x [NOT] LIKE pattern [ESCAPE c] (Item_func_like).
The operand is a bit_expr; the pattern and the escape character are simple_expr (MYSQL-PRECEDENCE-001). Without ESCAPE the escape character is the backslash, or none under NO_BACKSLASH_ESCAPES; that default is not written.
Rule: MYSQL-LIKE-001. Facts: 1, 0 or NULL, an integer; it can be NULL when an operand can. Every operand takes a single value. Terminates: the operands are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/string-comparison-functions.html#operator_like. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT a FROM t WHERE a LIKE 'x!%' ESCAPE '!'");
$query->statement->where->escape->value() // => '!'Properties§
public Scalar $operandpublic Scalar $patternpublic Scalar|null $escape = nullpublic bool $negated = falseMethods§
public function __construct(
public Scalar $operand,
public Scalar $pattern,
public Scalar|null $escape = null,
public bool $negated = false,
)Parameters
$operand | Scalar | The matched expression |
$pattern | Scalar | The pattern |
$escape | Scalar|null | The escape character, when ESCAPE is written |
$negated | bool | Whether NOT is written before LIKE |
Calls 7
- new Precedence line 48
- static-call Check::input() line 49
- method-call Precedence::fits() line 49
- class-const Precedence::PREDICATE() line 49
- class-const Precedence::BIT_EXPR() line 49
- method-call Precedence::admits() line 50
- class-const Precedence::SIMPLE_EXPR() line 50
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operands and combines their NULL facts.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- new Operands line 59
- method-call Operands::single() line 60
- method-call Derivation::scalar() line 60
- method-call Operands::truth() line 66
public function render(Output $out): voidWrites the operand, the optional NOT, LIKE, the pattern and the escape clause.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::node() line 74
- method-call Output::keyword() line 76
Test cases 5§
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 2
Relations§
Instantiated in 3
- new SqlSemantics\Platform\MySql\Lowering\Expression\PredicateRule::operation() packages/sql-semantics-mysql/src/Lowering/Expression/PredicateRule.php:93
- new SqlSemantics\Platform\MySql\Lowering\Expression\PredicateRule::operation() packages/sql-semantics-mysql/src/Lowering/Expression/PredicateRule.php:94
- new SqlSemantics\Platform\MySql\Lowering\Expression\PredicateRule::operation() packages/sql-semantics-mysql/src/Lowering/Expression/PredicateRule.php:95