Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PgQuery::Node: Add inner and inner= helpers to modify inner object #306

Merged
merged 2 commits into from
Jan 9, 2024

Commits on Jan 9, 2024

  1. PgQuery::Node: Add inner and inner= helpers to modify inner object

    Because of how oneof messages work in protobuf, its a bit tedious to
    make modifications to a Node object, in particular when changing the type
    of the inner object held within the Node in a generic code path (i.e.
    with a dynamic inner type), which required first knowing the name of the
    new inner object type, and then using public_send to set the new value.
    
    To help, introduce the new "inner" and "inner=" methods for PgQuery::Node,
    that get/set the inner object directly, avoiding the use of public_send.
    
    This will be of particular help for anyone utilizing the walk! API to
    make modifications to the query tree. To illustrate, an example is added
    to the treewalker spec showing how to utilize this.
    lfittl committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    2810b59 View commit details
    Browse the repository at this point in the history
  2. Treewalker: Allow passing a block with a single argument to walk!

    This simplifies the common use case of just working with the walked node
    directly, which is now sufficient more often thanks to the addition of
    Node#inner= streamling modification of Node objects without going to the
    parent to replace them.
    lfittl committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    3d7dcc4 View commit details
    Browse the repository at this point in the history