classWeightString
final class WeightString
implements Scalar
uses Snapshot
@visibility public.A call of WEIGHT_STRING(): the binary weight string of a string under its collation.
Rule: MYSQL-WEIGHT-STRING-001. The argument may be cast to CHAR(n) or BINARY(n) first; MySQL 5.6 and 5.7 also take a LEVEL clause of levels or a range of levels, and not after a BINARY cast. The result is a binary string; it is NULL when the argument is NULL. Terminates: the operand is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/string-functions.html#function_weight-string, https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_weight-string. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT WEIGHT_STRING('ab' AS CHAR(4))");
$query->field(0)->type->descriptor->name() // => 'VARBINARY'new \SqlSemantics\Platform\MySql\Statement\Call\Weight\WeightString(new \SqlSemantics\Platform\MySql\Statement\Literal\NullLiteral(), \SqlSemantics\Platform\MySql\Statement\Call\Weight\WeightCast::Binary, new \SqlSemantics\Platform\MySql\Statement\Literal\Numeral('4'), [new \SqlSemantics\Platform\MySql\Statement\Call\Weight\WeightLevel(new \SqlSemantics\Platform\MySql\Statement\Literal\Numeral('1'))]) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstructionProperties§
public list<WeightLevel> $levelspublic Scalar $subjectpublic WeightCast|null $cast = nullpublic Numeral|null $length = nullpublic WeightLevelRange|null $range = nullMethods§
public function __construct(
public Scalar $subject,
public WeightCast|null $cast = null,
public Numeral|null $length = null,
list<WeightLevel> $levels = [],
public WeightLevelRange|null $range = null,
)Parameters
$subject | Scalar | The string |
$cast | WeightCast|null | The type the string is cast to |
$length | Numeral|null | The length of the cast; present exactly with a cast |
$levels | list<WeightLevel> | The levels of the LEVEL clause |
$range | WeightLevelRange|null | The range of the LEVEL clause |
Calls 4
- static-call Check::listOf() line 60
- class-const WeightLevel::class() line 60
- static-call Check::input() line 61
- class-const WeightCast::Binary() line 63
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operand; the result is a binary string.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- method-call ResultTyping::fact() line 71
- new ResultTyping line 71
- method-call Arguments::one() line 71
- new Arguments line 71
public function render(Output $out): voidWrites the call.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::keyword() line 79
- method-call Output::symbol() line 86
Test cases 4§
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 2
Relations§
Instantiated in 3
- new SqlSemantics\Platform\MySql\Lowering\Call\WeightRule::call() packages/sql-semantics-mysql/src/Lowering/Call/WeightRule.php:88
- new SqlSemantics\Platform\MySql\Lowering\Call\WeightRule::call() packages/sql-semantics-mysql/src/Lowering/Call/WeightRule.php:93
- new SqlSemantics\Platform\MySql\Lowering\Call\WeightRule::call() packages/sql-semantics-mysql/src/Lowering/Call/WeightRule.php:94