You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve nested table qualifiers in MySQL upsert policy filters #2911
MySQL upserts using ON DUPLICATE KEY UPDATE can strip table qualifiers from nested computed-field expressions in update policy filters. When a nested query uses the mutation model name as a table name or alias, stripping that qualifier can make column references ambiguous, for example when the nested query joins another table with the same column name.
The reported case involves an update policy using a computed field whose implementation queries its own model table without an alias. This case was not tested in the original pull request.
Required changes
Make TableReferenceStripper in packages/plugins/policy/src/policy-handler.ts aware of query scope when it processes duplicate-key update policy filters.
Preserve references to tables and aliases declared in nested queries, including names that match the mutation model.
Handle correlated references to the outer mutation model correctly. Review the computed-field policy expression path in packages/plugins/policy/src/expression-transformer.ts.
Acceptance criteria
Add a MySQL regression test for an upsert with an update policy using a computed field whose nested query joins tables with a shared column name and references the mutation model name.
Verify that nested table qualifiers remain intact and the upsert evaluates the policy without an ambiguous-column error.
Add coverage for correlated outer references and ordinary duplicate-key update policy filters, including allowed and denied updates.
Activity