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

A call of POSITION(substring IN string): the position of the first occurrence, 0 when there is none.

Rule: MYSQL-POSITION-CALL-001. The server builds LOCATE(substring, string): an integer that is NULL when an argument is. The substring is an arithmetic operand (bit_expr) that ends before IN; an operand that would absorb IN needs a grouping and is refused. Terminates: the operands are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/string-functions.html#function_position. Status: Implemented.

Reading both operands of POSITION()doctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT POSITION('b' IN 'abc')");
    $query->field(0)->type->descriptor->name() // => 'BIGINT'

Properties§

public Scalar $substring
public Scalar $string

Methods§

public function __construct(public Scalar $substring, public Scalar $string)

Parameters

$substringScalarThe string to find; an arithmetic operand
$stringScalarThe string to search
Calls 6
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operands; the result is an integer.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the call.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 3§

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

Dedicated tests 2
Other tests reaching this symbol 1

Relations§

Instantiated in 1