classNumericConstant
final class NumericConstant
implements Node
uses Snapshot
@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.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1_0.50e-3');
$query->statement->targets[0]->expression->value->text // => '1_0.50e-3'new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NumericConstant('100') // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public string $textMethods§
public function __construct(public string $text)Parameters
$text | string | The written text, without a sign |
Calls 3
- static-call Check::input() line 44
- method-call Numerals::kept() line 44
- new Numerals line 44
public function render(Output $out): voidWrites the text as it was written.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::spelled() line 52
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
LiteralsTest::testNumberLowersAnIntegerOrNumericConstantcallsObjectIdentifiersTest::testProblemRejectsANegativeValueBeyondTheSignExtensioncallsObjectIdentifiersTest::testProblemRejectsAValueOfMoreThanTenDigitscallsPrefixTypingTest::testNegativeTypesByValuecallsPrefixTypingTest::testPrefixFoldsANegativeConstantcallsArgumentTextTest::testIntegerAnswersOnlyThirtyTwoBitIntegerscallsArgumentTextTest::testNumberWritesTheTextOfAFloatAsWrittencallsAttributeReaderTest::testReadKeepsARejectedValueAsWrittencallsOptionArgumentsTest::testBooleanRefusesOtherValuescallsOptionArgumentsTest::testIntegerReadsIntegersThatFitIn32BitscallsRoleConnectionLimitTest::testRejectsAFractioncallsBinaryOperationTest::testDeriveScalarPromotesAnIntegerAndANumericcallsUnaryOperationTest::testDeriveScalarKeepsTheTypeOfANegatedNumbercallsUnaryOperationTest::testDeriveScalarTypesANegativeConstantByItsValuecallsMinMaxTest::testDeriveScalarIsTheCommonTypecallsConstantTest::testBuiltinFollowsTheSizeOfAnIntegercallsConstantTest::testBuiltinOfTheOtherConstantscallsConstantTest::testIntegerValueReadsIntegersAndStringsThatSpellOnecallsSignedNumberTest::testRenderWritesTheMinusSigncallsSignedNumberTest::testTextIsTheIntegerValueOrTheWrittenTextAfterTheSigncallsIntegerArgumentTest::testRejectsANumberWithAPointcallsUtilityOptionTest::testTextAnswersTheValueAsTheServerReceivesItcalls
Relations§
Instantiated in 1
Type checks 4
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::prefix() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:50
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\FetchCounts::admits() packages/sql-semantics-postgres/src/Rules/Query/FetchCounts.php:37
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::builtin() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:58
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Literal\SignedNumber::text() packages/sql-semantics-postgres/src/Statement/Literal/SignedNumber.php:49
Type declarations 6
- type SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:84
- type SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:109
- type SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:60
- type SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:46
- type SqlSemantics\Platform\PostgreSql\Statement\Literal\SignedNumber packages/sql-semantics-postgres/src/Statement/Literal/SignedNumber.php:40
- type SqlSemantics\Platform\PostgreSql\Statement\Table\Trigger\TriggerArgument packages/sql-semantics-postgres/src/Statement/Table/Trigger/TriggerArgument.php:36