We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
How is it possible to add a column to an existing query after we have converted it into a parsed tree
The text was updated successfully, but these errors were encountered:
q = PgQuery.parse("SELECT a FROM tbl") q.tree.stmts[0].stmt.select_stmt.target_list.push( PgQuery::Node.new( res_target: PgQuery::ResTarget.new( val: PgQuery::Node.new( column_ref: PgQuery::ColumnRef.new( fields: [PgQuery::Node.new(string: PgQuery::String.new(sval: 'b'))] ) ) ) ) ) q.deparse => "SELECT a, b FROM tbl"
Sorry, something went wrong.
Note that if you add two elements to the column_ref array it will qualify the name with a period:
column_ref: PgQuery::ColumnRef.new( fields: [PgQuery::Node.new(string: PgQuery::String.new(sval: 'tbl'))], fields: [PgQuery::Node.new(string: PgQuery::String.new(sval: 'b'))] ) q.deparse => "SELECT a, tbl.b FROM tbl"
Thanks for opening the issue as discussed & sharing the solution I've shared via email!
No branches or pull requests
How is it possible to add a column to an existing query after we have converted it into a parsed tree
The text was updated successfully, but these errors were encountered: