classSimilarSubstring
final class SimilarSubstring
implements Scalar, OutputNaming
uses Snapshot
@visibility public.SUBSTRING (string SIMILAR pattern ESCAPE escape): the part of a string a SQL regular expression marks.
The server calls pg_catalog.substring(string, pattern, escape). Rule: PG-SIMILAR-SUBSTRING-001. Facts: those of the call (PG-CALL-RESULT-001; text). The result column is named substring. SIMILAR follows the string at the level of the pattern operators, and ESCAPE continues an open pattern match at the end of the pattern, so an operand that would lose its place there is rejected. Source: https://www.postgresql.org/docs/17/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP. Status: Implemented.
$null = static fn () => new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral();
(new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\SimilarSubstring($null(), $null(), $null()))->outputName()->value // => 'substring'Properties§
public Scalar $stringpublic Scalar $patternpublic Scalar $escapeMethods§
public function __construct(
public Scalar $string,
public Scalar $pattern,
public Scalar $escape,
)Parameters
$string | Scalar | The string |
$pattern | Scalar | The SQL regular expression |
$escape | Scalar | The escape character |
Calls 5
- new Precedence line 46
- static-call Check::input() line 47
- method-call Precedence::before() line 47
- class-const Precedence::PATTERN() line 47
- method-call Precedence::takesEscape() line 48
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 3
- method-call Derivation::scalar() line 64
- method-call CallTyping::catalog() line 66
- new CallTyping line 66
public function render(Output $out): voidWrites SUBSTRING with SIMILAR and ESCAPE.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::keyword() line 74
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
SimilarSubstringTest::testDeriveScalarIsTextcallsSimilarSubstringTest::testOutputNameIsSubstringcallsSimilarSubstringTest::testRejectsAPatternThatWouldTakeTheEscapecallsSimilarSubstringTest::testRejectsAStringThatWouldLoseItsPlaceBeforeSimilarcallsSimilarSubstringTest::testRenderWritesTheKeywordscalls