pganalyze / pg_query

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

Breaking changes in google-protobuf 4+ #314

Open dark-panda opened 5 months ago

dark-panda commented 5 months ago

The release of google-protobuf 4 cause pg_query to throw exceptions when the older Ruby DSL methods are used. For instance:

NoMethodError: undefined method `build' for #<Google::Protobuf::DescriptorPool:0x000000010ceb94b8> (NoMethodError)

Google::Protobuf::DescriptorPool.generated_pool.build do
                                               ^^^^^^
~/.bundles/securicy-app/ruby/3.2.0/gems/pg_query-2.2.1/lib/pg_query/pg_query_pb.rb:6:in `<top (required)>'

The change in google-protobuf is here: https://github.com/protocolbuffers/protobuf/commit/5cfc9e775d76acb37e5b554e53dff336a89d000f

Announcement of the breaking changes is the: https://protobuf.dev/news/2023-04-20/

wflanagan commented 5 months ago

I've hit this too.. any updates on a fix?

mcg commented 4 months ago

Hit this today trying to go to Ruby 3.3. Any ETA on Fix?

lfittl commented 4 months ago

We haven't triaged this in detail yet - for now the recommendation would be to pin google-protobuf to an older version until we've made the necessary changes.

For those running into this, is there a requirement to move to the newer google-protobuf?

viktorianer commented 3 months ago

Hey @dark-panda Can you make me remember, how I can reproduce this error?

Because, I do remember, I saw exact the same trace, but can not reproduce it anymore on my app with Rails 7.0.8.1 and Ruby 3.3.

I am working an upgrade from Dependabot, where I had before: gem "google-protobuf", "~> 3.25", ">= 3.25.3"

And now: gem "google-protobuf", "~> 4.26

And everything works 💯.

Also, the gem prosopite, which depends on pg_query, works as expected.