pganalyze / pg_query

Ruby extension to parse, deparse and normalize SQL queries using the PostgreSQL query parser
BSD 3-Clause "New" or "Revised" License
778 stars 84 forks source link

Treewalker: Yield for each array element itself, not just children #303

Closed lfittl closed 8 months ago

lfittl commented 9 months ago

Due to an oversight in how the treewalker was implemented, we would never pass the direct array elements to the walk! block, only any children the elements have.

In practice this is usually not an issue, since the array elements are typically the generic PgQuery::Node object, and we would call the walk! function successfully on its children. However, working with those node objects directly is necessary when wanting to replace the node.

This may be a backwards incompatible change if one relies on the parent_field to always be a symbol (it can now be an integer as well).