final class NumericConstant
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

A numeric constant the server keeps as its written text: one written with a decimal point or an exponent, or an integer too large for 32 bits.

The scanner reads such a constant as an FCONST, and the raw parser stores it as a T_Float node holding the written text, not a number. The text is the value: an expression reads it as bigint or numeric when its type is known, where 0001.50 is the numeric 1.50 with two fraction digits, but SET, storage parameters, trigger arguments and other options receive the text verbatim, so SET application_name = 1e2 sets 1e2 and 0x1FFFFFFFFF stays 0x1FFFFFFFFF. The text is kept exactly, digit separators, letter case and leading zeros included, and written back as it is (PG-LEX-NUMBER-001). Source: https://www.postgresql.org/docs/17/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS-NUMERIC, makeFloat and NumericOnly in src/backend/parser/gram.y of PostgreSQL 17.

Reading the text of a numeric constantdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1_0.50e-3');
    $query->statement->targets[0]->expression->value->text // => '1_0.50e-3'
Rejecting an integer the scanner reads as an integer constantdoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NumericConstant('100') // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public string $text

Methods§

public function __construct(public string $text)

Parameters

$textstringThe written text, without a sign
Calls 3
public function render(Output $out): void

Writes the text as it was written.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 27§

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

Dedicated tests 5
Other tests reaching this symbol 22

Relations§

Instantiated in 1
Type checks 4
Type declarations 6