Skip to content

How to add WHERE clause to a query #295

@kduraiswami

Description

@kduraiswami

I am trying to inject my own where clauses into a SQL statement

I can access the node here:  parsed_query.tree.stmts[0].stmt.select_stmt.where_clause 

next_item = condition_items.shift

I am trying to understand, is it always an :a_expr if it is one where_clause and a :bool_expr if it has an "AND"?

Am I correct that I would have to create my own new where_clause node this:

<PgQuery::Node.new 
    bool_expr: <PgQuery::BoolExpr.new boolop: :AND_EXPR 

And then put my own clauses in there using the and? Would there happen to be any code sample for creating a new where_clause? Thank you for the help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions