classTrim
final class Trim
implements Scalar, OutputNaming
uses Snapshot
@visibility public.TRIM ([LEADING | TRAILING | BOTH] [characters] FROM strings) and the forms without FROM.
The server calls pg_catalog.btrim, ltrim or rtrim with the strings written and then the characters, if written before FROM. BOTH, and FROM without characters, are the defaults and are not kept. Rule: PG-TRIM-001. Facts: those of the call (PG-CALL-RESULT-001; text, or bytea for byte strings). The result column is named after the function called. Source: https://www.postgresql.org/docs/17/functions-string.html. Status: Implemented.
$trim = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Trim(\SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\TrimSide::Trailing, null, [new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()]);
$trim->outputName()->value // => 'rtrim'Properties§
public non-empty-list<Scalar> $stringspublic TrimSide $sidepublic Scalar|null $charactersMethods§
public function __construct(
public TrimSide $side,
public Scalar|null $characters,
list<Scalar> $strings,
)Parameters
$side | TrimSide | The ends trimmed |
$characters | Scalar|null | The characters removed, written before FROM |
$strings | list<Scalar> | The strings trimmed; at least one |
Calls 2
- static-call Check::listOf() line 49
- class-const Scalar::class() line 49
public function outputName(): NameNames an unaliased result column after the function the server calls.
Returns
Test cases 1
Calls 2
- new Name line 57
- method-call TrimSide::function() line 57
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operands and the result of the trim function.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- method-call Derivation::scalar() line 65
- method-call CallTyping::catalog() line 74
- new CallTyping line 74
- method-call TrimSide::function() line 74
public function render(Output $out): voidWrites TRIM with the side, the characters and the strings.
Parameters
$out | Output |
Test cases 1
Calls 4
- method-call Output::keyword() line 82
- class-const TrimSide::Both() line 83
- method-call Output::node() line 87
- method-call Output::list() line 89
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 3
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\TextRule::trim() packages/sql-semantics-postgres/src/Lowering/Invocation/TextRule.php:177
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\TextRule::trim() packages/sql-semantics-postgres/src/Lowering/Invocation/TextRule.php:178
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\TextRule::trim() packages/sql-semantics-postgres/src/Lowering/Invocation/TextRule.php:179