classExpressionBinder
final class ExpressionBinder
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Expression binder operations for PostgreSQL upsert.
Methods§
public function __construct(
non-empty-list<string> $incomingNamespaces,
IdentifierQuoter $quoter,
)Supplies the dependencies used by this ExpressionBinder.
Parameters
$incomingNamespaces | non-empty-list<string> | |
$quoter | IdentifierQuoter |
public function bindExpression(
string $expression,
string $tableName,
list<string> $tableColumns,
string $unqualifiedAlias = self::EXISTING_ALIAS,
): stringParameters
$expression | string | |
$tableName | string | |
$tableColumns | list<string> | |
$unqualifiedAlias | string |
Returns
stringTest cases 1
Called from 4
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\ConflictPredicate::withPredicate() packages/ztd-query-postgres/src/Rewrite/Upsert/ConflictPredicate.php:61
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\ConflictPredicate::withPredicate() packages/ztd-query-postgres/src/Rewrite/Upsert/ConflictPredicate.php:67
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:69
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:74
Calls 14
- class-const ExpressionBinder::EXISTING_ALIAS() line 45
- static-call SqlTokenStream::tokenize() line 47
- static-call PgSqlLexerProfile::create() line 47
- method-call ExpressionBinder::subqueryTokenIndexes() line 48
- function-call
array_fill_keysline 50 - function-call
array_mapline 50 - method-call ExpressionBinder::isIdentifier() line 54
- method-call ExpressionBinder::identifier() line 60
- method-call ExpressionBinder::qualifiedReplacement() line 64
- function-call
strtolowerline 71 - function-call
strlenline 76 - method-call ConflictPredicate::qualified() line 77
- new ConflictPredicate line 77
- method-call ExpressionBinder::applyReplacements() line 81
public function subqueryTokenIndexes(list<SqlToken> $tokens): array<int, true>public function isIdentifier(SqlToken $token): boolIs identifier.
Parameters
$token | SqlToken |
Returns
boolTest cases 1
Called from 2
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\ExpressionBinder::bindExpression() packages/ztd-query-postgres/src/Rewrite/Upsert/ExpressionBinder.php:54
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\ExpressionBinder::bindExpression() packages/ztd-query-postgres/src/Rewrite/Upsert/ExpressionBinder.php:63
Calls 3
- function-call
in_arrayline 112 - class-const SqlTokenKind::Word() line 112
- class-const SqlTokenKind::QuotedIdentifier() line 112
public function identifier(SqlToken $token): stringIdentifier.
Parameters
$token | SqlToken |
Returns
stringTest cases 1
Called from 2
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\ExpressionBinder::bindExpression() packages/ztd-query-postgres/src/Rewrite/Upsert/ExpressionBinder.php:60
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\ExpressionBinder::qualifiedReplacement() packages/ztd-query-postgres/src/Rewrite/Upsert/ExpressionBinder.php:139
Calls 2
- static-call SqlTokenStream::tokenize() line 120
- static-call PgSqlLexerProfile::create() line 120
public function qualifiedReplacement(
SqlToken $token,
SqlToken $afterNext,
string $name,
string $tableName,
array<string, true> $incomingNamespaces,
): array{offset: int, length: int, value: string}|nullBinds only an incoming or target-table qualifier, leaving other namespaces untouched.
Parameters
Returns
array{offset: int, length: int, value: string}|nullCalled from 1
Calls 8
- function-call
strtolowerline 131 - class-const ExpressionBinder::INCOMING_ALIAS() line 133
- function-call
strcasecmpline 134 - class-const ExpressionBinder::EXISTING_ALIAS() line 134
- method-call SqlToken::endOffset() line 138
- method-call ConflictPredicate::qualified() line 139
- new ConflictPredicate line 139
- method-call ExpressionBinder::identifier() line 139
public function applyReplacements(
string $expression,
list<array{offset: int, length: int, value: string}> $replacements,
): stringReplaces bound identifiers from right to left to preserve earlier source offsets.
Parameters
$expression | string | |
$replacements | list<array{offset: int, length: int, value: string}> |
Returns
stringTest cases 1
Called from 1
Private surface 4§
Implementation details, listed for orientation only.
private const INCOMING_ALIAS = '__ztd_incoming'private const EXISTING_ALIAS = '__ztd_existing'private non-empty-list<string> $incomingNamespacesprivate IdentifierQuoter $quoterTest cases 14§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
ExpressionBinderTest::testApplyReplacementsPreservesEarlierOffsetscallsExpressionBinderTest::testBindExpressioncallsExpressionBinderTest::testIdentifiercallsExpressionBinderTest::testIsIdentifiercallsExpressionBinderTest::testQualifiedReplacementBindsOnlyRecognizedNamespacescallsExpressionBinderTest::testSubqueryTokenIndexescalls
Other tests reaching this symbol 8
PgSqlSessionFactoryTestcallsPgSqlRewriterTestcallsStatementRewriterTestcallsUpsertProjectionTestcallsInsertTransformerTestcallsPgSqlTransformerTestcallsConflictPredicateTestcallsPgSqlNativeUpsertProjectorTestcalls
Relations§
Instantiated in 4
- new ZtdQuery\Platform\Postgres\Rewrite\Upsert\ConflictPredicate::withPredicate() packages/ztd-query-postgres/src/Rewrite/Upsert/ConflictPredicate.php:61
- new ZtdQuery\Platform\Postgres\Rewrite\Upsert\ConflictPredicate::withPredicate() packages/ztd-query-postgres/src/Rewrite/Upsert/ConflictPredicate.php:67
- new ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:69
- new ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:74
Method calls 4
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\ConflictPredicate::withPredicate() packages/ztd-query-postgres/src/Rewrite/Upsert/ConflictPredicate.php:61
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\ConflictPredicate::withPredicate() packages/ztd-query-postgres/src/Rewrite/Upsert/ConflictPredicate.php:67
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:69
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:74