pganalyze / pg_query

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

In prepared statements, no tables show as used #269

Closed directionless closed 1 year ago

directionless commented 1 year ago

Hi! I recognize this might be an artifact of the underlying PG libraries, but I wanted to mention it for general reference. Might not be anything to do other than WONTFIX

I notice that parsing a prepared statement, there are no tables flagged as being used:

pry(main)> parsed_query = PgQuery.parse 'PREPARE qux AS SELECT bar from foo'
=> #<PgQuery::ParserResult:0x000000012514f958
pry(main)> parsed_query.tables_with_details
=> []
lfittl commented 1 year ago

Thanks for reporting - that's just an oversight in the logic that finds the table names - easy fix (see PR) :)

directionless commented 1 year ago

Nice. Thank you