Index Suggestions do not work with PgQuery 4.2.0
natematykiewicz opened this issue · comments
I followed the instructions to set up Index Suggestions.
gem "pg_query", ">= 2"
Looks like PgQuery went from v2.2.1 to v4.2.0 last February.
https://github.com/pganalyze/pg_query/blob/main/CHANGELOG.md
Since this was a fresh install, I got the latest version.
What I experienced was that any time I include a WHERE clause, I just get "Unknown structure".
PgHero.best_index('select id from users where id = 1')
=> {:found=>false, :explanation=>"Unknown structure"}
After a lot of digging, I found the problem was:
undefined method `str' for <PgQuery::String: sval: "=">:PgQuery::String
Changing my Gemfile to this fixes it. It installs v2.2.1.
gem "pg_query", ">= 2", "< 4"
Hey @natematykiewicz, thanks for reporting. Just pushed a fix for the str
issue (and need to follow up w/ pg_query about parsing queries normalized with ?
). fwiw, 4.2.0 was released this month (the year in the changelog is off).
the year in the changelog is off
That makes way more sense. So it's not even been 2 weeks then.
Thanks for sorting this so quickly!