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

The BINARY operator: BINARY x, the cast of a value to a binary string (Item_typecast_char with the binary character set).

It binds as tightly as COLLATE and groups to the right, so BINARY a COLLATE c casts the collated value (MYSQL-PRECEDENCE-001). The operator is deprecated from MySQL 8.0.27 and still accepted.

Rule: MYSQL-BINARY-OPERATOR-001. Facts: a VARBINARY; NULL when the operand is. Terminates: the operand is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/cast-functions.html#operator_binary. Status: Implemented.

Typing a binary castdoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT a FROM t WHERE BINARY a = 'x'");
    $query->facts->scalar($query->statement->where->left)->type->descriptor->name() // => 'VARBINARY'

Properties§

public Scalar $operand

Methods§

public function __construct(public Scalar $operand)

Parameters

$operandScalarThe cast expression
Calls 4
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operand; the result is a binary string.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes BINARY and the operand.

Parameters

$outOutput
Calls 1

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 1
Type checks 1