-
Notifications
You must be signed in to change notification settings - Fork 85
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
"user" table_name is not considered by the library #258
Comments
The parse tree seems to indicate that your query is actually interpreted as "SELECT * FROM current_user()". I think this is an escaping issue in your input - if you put the
|
Thanks for pointing it out. But is there any other approach for this? Instead of having an additional quotes around the table_name? For other table_names, this works fine without the quotes around it. We can't specify that for "user" table, wrap it around a quote. |
I'm not sure I'm following - your query has a different intent when there are no quotes, as you are not referencing that Where are you getting your query texts from? I'm surprised why you don't have correct escaping on the input queries you are working with. |
Hi,
In our sql query, the table_name is "user". But this is not been considered when I parsed and try to get the table_names.
`irb(main):010:0> query = "select * from user"
=> "select * from user"
irb(main):011:0> @parsed_query = PgQuery.parse(query)
=> #<PgQuery:0x00000009d56638 @query="select * from user", @tree=[{"SelectStmt"=>{"targetList"=>[{"ResTarget"=>{"val"=>{"ColumnRef"=>{"fields"=>[{"A_Star"=>{}}], "location"=>7}}, "location"=>7}}], "fromClause"=>[{"RangeFunction"=>{"functions"=>[[{"FuncCall"=>{"funcname"=>[{"String"=>{"str"=>"pg_catalog"}}, {"String"=>{"str"=>"current_user"}}], "location"=>14}}, nil]]}}], "op"=>0}}], @warnings=[]>
irb(main):012:0> @parsed_query.tables
=> []`
Let me know if we would need to do any change to accommodate this?
TIA
The text was updated successfully, but these errors were encountered: