Skip to content

Conversation

@pyramation
Copy link
Collaborator

fix(plpgsql-deparser): handle = assignment operator in splitAssignment

Summary

PL/pgSQL allows both := and = for variable assignments, but splitAssignment() only recognized :=. This caused = assignments to fail hydration and become kind: 'raw' without valueExpr/targetExpr, preventing AST-based transformations (like schema renaming) from working.

This fix adds = as a valid assignment operator while avoiding false positives from:

  • Comparison operators: >=, <=, <>, !=
  • Named parameter syntax: =>

Review & Testing Checklist for Human

  • Verify = detection edge cases: The logic checks if the previous token is >, <, !, or : to skip comparison operators. Confirm this covers all cases where = should NOT be treated as assignment.
  • Check unused variable: assignTokenText is set but never used - should it be removed or is it needed for future use?
  • Test fallback consistency: The catch block fallback has slightly different logic (checks both prev AND next characters) vs main logic (only checks prevToken). Verify this inconsistency doesn't cause issues.

Recommended test plan:

  1. Run pnpm --filter plpgsql-deparser test to verify all tests pass
  2. Test with the downstream constructive-db schema transformer to verify = assignments now get their schema names transformed correctly

Notes

PL/pgSQL allows both := and = for assignments. Previously, splitAssignment()
only recognized :=, causing = assignments to fail hydration and become
kind: 'raw' without valueExpr/targetExpr. This prevented AST-based
transformations (like schema renaming) from working on = assignments.

This fix:
- Adds = as a valid assignment operator in splitAssignment()
- Avoids false positives from comparison operators (>=, <=, <>, !=)
- Avoids false positives from => (named parameter syntax)
- Adds test case for = assignment hydration
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 670f006 into main Jan 6, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants