classSubstring
final class Substring
implements Scalar, OutputNaming
uses Snapshot
@visibility public.SUBSTRING (string FROM start FOR count) and its partial forms.
The server calls pg_catalog.substring(string, start[, count]). With FOR alone it passes 1 as the start and the count cast to integer; FOR may also be written before FROM, which the model keeps because the tokens differ. With FROM alone and a text start the call is the POSIX pattern form. Rule: PG-SUBSTRING-001. Facts: those of the call (PG-CALL-RESULT-001; the type of the string for text, bytea and bit). The result column is named substring. Source: https://www.postgresql.org/docs/17/functions-string.html. Status: Implemented.
$substring = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Substring(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral(), null, new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral());
[$substring->start, $substring->outputName()->value] // => [null, 'substring']new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Substring(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public Scalar $stringpublic Scalar|null $start = nullpublic Scalar|null $count = nullpublic bool $countFirst = falseMethods§
public function __construct(
public Scalar $string,
public Scalar|null $start = null,
public Scalar|null $count = null,
public bool $countFirst = false,
)Parameters
$string | Scalar | The string |
$start | Scalar|null | The position of the first character, after FROM |
$count | Scalar|null | The number of characters, after FOR |
$countFirst | bool | Whether FOR is written before FROM |
Calls 1
- static-call Check::input() line 52
public function outputName(): NameNames an unaliased result column after the function the server calls.
Returns
Test cases 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operands and the result of pg_catalog.substring.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 7
- method-call Derivation::scalar() line 69
- new ScalarFact line 70
- new Known line 70
- class-const Builtin::Int4() line 70
- class-const Nullability::NotNull() line 70
- method-call CallTyping::catalog() line 77
- new CallTyping line 77
public function render(Output $out): voidWrites SUBSTRING with FROM and FOR in the order written.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::keyword() line 85
- method-call Output::symbol() line 95
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 4
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\TextRule::substring() packages/sql-semantics-postgres/src/Lowering/Invocation/TextRule.php:157
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\TextRule::substring() packages/sql-semantics-postgres/src/Lowering/Invocation/TextRule.php:158
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\TextRule::substring() packages/sql-semantics-postgres/src/Lowering/Invocation/TextRule.php:159
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\TextRule::substring() packages/sql-semantics-postgres/src/Lowering/Invocation/TextRule.php:160