Plinq / pgcrypto

A transparent ActiveRecord::Base extension pgcrypto encrypted columns
MIT License
40 stars 18 forks source link

rails 4.2.0 , arel 6.0 compatibility? #5

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi, Great gem, I was wondering if you might have some insight about an issue I'm having which I think is due to Arel 6.0 upgrade. In Arel 5.0 BindParams < SqlLiteral < String < Object < BasicObject , but in Arel 6.0 BindParams < Node < Object < BasicObject. I assume this is the reason I get the message:

TypeError: wrong argument type Arel::Nodes::BindParam (expected String) from ... /vendor/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql/quoting.rb:19:in escape_string' from ... /vendor/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql/quoting.rb:19:inquote_string' from ... /vendor/ruby/2.2.0/gems/pgcrypto-0.4.1/lib/pgcrypto/adapter.rb:51:in `pgcrypto_encrypt_string'

More info on stack exchange here: (http://stackoverflow.com/questions/29102190/postgres-9-4-pgcrypto-0-4-1-rails-4-2-0-ruby-2-2-0-quoting-expected-string) , happy to help out with a pull request but I'm not clear on how to get a value out of Arel::Nodes::BindParam. I suspect the problem line is in pgcrypto_insert line 64 and pgcrypto_update line 98 (possibly other areas as well) where you are pulling a value from Arel::Nodes::BindParam.

thanks

modosc commented 9 years ago

i worked around this with some patches to arel which makes me think i'm not doing it right. feel free to check out my branches

yeah, on second thought don't do that. patches don't work in all cases, sorry.