classCastResult
final class CastResult
Derives the type and NULL fact of a cast to a target type.
Rule: MYSQL-CAST-RESULT-001. BINARY[(n)] is VARBINARY[(n)]; CHAR[(n)] is VARCHAR[(n)] with its character set attribute, NCHAR the national VARCHAR; SIGNED and UNSIGNED are BIGINT; DATE, TIME[(p)], DATETIME[(p)], YEAR and DECIMAL[(m[,d])] are those types; JSON is JSON; DOUBLE is DOUBLE; FLOAT is FLOAT without a precision or with one of at most 24 and DOUBLE otherwise; REAL is FLOAT under the session mode REAL_AS_FLOAT and DOUBLE otherwise: the profile does not hold the mode, so the type is the known choice of FLOAT and DOUBLE; the spatial targets are their geometry types. A cast to a temporal type or YEAR yields NULL for a value that is not a valid date or time, so it can always be NULL; every other cast is NULL only when its operand is. Terminates: no recursion. Source: https://dev.mysql.com/doc/refman/8.4/en/cast-functions.html#function_cast. Status: Implemented.
Methods§
public function type(CastTarget $target): TypeFactAnswers the type of a cast to a target.
Parameters
$target | CastTarget |
Returns
Test cases 1
Called from 1
Calls 43
- class-const CastKind::Binary() line 66
- new Known line 66
- new Binary line 66
- class-const BinaryKind::VarBinary() line 66
- class-const CastKind::Char() line 67
- new Character line 67
- class-const CharacterKind::VarChar() line 67
- class-const CastKind::NationalChar() line 68
- class-const CastKind::Signed() line 69
- new Integral line 69
- class-const IntegralKind::BigInt() line 69
- class-const CastKind::Unsigned() line 70
- class-const NumericModifier::Unsigned() line 70
- class-const CastKind::Date() line 71
- new Temporal line 71
- class-const TemporalKind::Date() line 71
- class-const CastKind::Time() line 72
- class-const TemporalKind::Time() line 72
- class-const CastKind::DateTime() line 73
- class-const TemporalKind::DateTime() line 73
- class-const CastKind::Year() line 74
- class-const TemporalKind::Year() line 74
- class-const CastKind::Decimal() line 75
- new Decimal line 75
- class-const CastKind::Json() line 76
- new Elementary line 76
- class-const ElementaryKind::Json() line 76
- class-const CastKind::Real() line 77
- new Choice line 77
- new Floating line 77
- class-const FloatingKind::Float() line 77
- class-const FloatingKind::Double() line 77
- class-const CastKind::Double() line 78
- class-const CastKind::Float() line 79
- class-const CastKind::Point() line 80
- class-const CastKind::LineString() line 80
- class-const CastKind::Polygon() line 80
- class-const CastKind::MultiPoint() line 80
- class-const CastKind::MultiLineString() line 80
- class-const CastKind::MultiPolygon() line 81
- class-const CastKind::GeometryCollection() line 81
- new Spatial line 81
- class-const CastResult::SPATIAL() line 81
public function nullability(CastTarget $target, Nullability $operand): NullabilityAnswers the NULL fact of a cast to a target of an operand with a NULL fact.
Parameters
$target | CastTarget | |
$operand | Nullability |
Returns
Test cases 1
Called from 1
Calls 6
- function-call
in_arrayline 90 - class-const CastKind::Date() line 90
- class-const CastKind::Time() line 90
- class-const CastKind::DateTime() line 90
- class-const CastKind::Year() line 90
- class-const Nullability::Nullable() line 92
Private surface 1§
Implementation details, listed for orientation only.
private const SPATIAL = ['POINT' => \SqlSemantics\Platform\MySql\Statement\Type\Kind\SpatialKind::Point…Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Relations§
Instantiated in 1
Method calls 2
- method-call SqlSemantics\Platform\MySql\Statement\Expression\Conversion\Cast::deriveScalar() packages/sql-semantics-mysql/src/Statement/Expression/Conversion/Cast.php:66
- method-call SqlSemantics\Platform\MySql\Statement\Expression\Conversion\Cast::deriveScalar() packages/sql-semantics-mysql/src/Statement/Expression/Conversion/Cast.php:66