Skip to content

Conversation

@pyramation
Copy link
Collaborator

Summary

Fixes a bug where hydratePlpgsqlAst would crash with TypeError: query.indexOf is not a function when called on an already-hydrated AST. This occurred because hydrateExpression expected query to always be a string, but when processing an already-hydrated AST, the query property is a HydratedExprQuery object.

The fix adds a check at the beginning of hydrateExpression to detect if the query is already hydrated (using the existing isHydratedExpr function) and return it unchanged.

Use case: This is needed for schema transformation pipelines where the same AST might be processed multiple times, such as in constructive-db's schema name transformer.

Review & Testing Checklist for Human

  • Verify the isHydratedExpr function correctly identifies all hydrated expression kinds (raw, sql-stmt, sql-expr, assign)
  • Confirm the type signature change from query: string to query: string | HydratedExprQuery doesn't cause TypeScript issues downstream
  • Run full test suite: pnpm test in packages/plpgsql-deparser

Test plan: After merging and publishing, update constructive-db to use the new version and verify the schema transformation pipeline works without the query.indexOf error.

Notes

…Expression

The hydrateExpression function now checks if the query is already a
HydratedExprQuery object and returns it unchanged. This fixes the
'query.indexOf is not a function' error that occurred when calling
hydratePlpgsqlAst on an already hydrated AST.

This is important for use cases where the same AST might be processed
multiple times, such as in schema transformation pipelines.
@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 5d3772b 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