classExtract
final class Extract
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.A call of EXTRACT(unit FROM date): the part of a date or time a unit names.
Rule: MYSQL-EXTRACT-CALL-001. The result is an integer; it is NULL when the argument is NULL or not a valid date or time. Terminates: the operand is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_extract. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT EXTRACT(YEAR_MONTH FROM '2024-07-02')");
$query->field(0)->type->descriptor->name() // => 'BIGINT'Properties§
public IntervalUnit $unitpublic Scalar $sourceMethods§
public function __construct(public IntervalUnit $unit, public Scalar $source)Parameters
$unit | IntervalUnit | The part to extract |
$source | Scalar | The date or time |
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operand; the result is an integer.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- method-call ResultTyping::fact() line 48
- new ResultTyping line 48
- method-call Arguments::one() line 48
- new Arguments line 48
public function render(Output $out): voidTest cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.