On Friday, May 29, 2020 at 9:13:52 AM UTC-7, Tiago Cardoso wrote:
>
> This pertains the [CI builds of sequel-activerecord_connection](
> https://travis-ci.org/github/janko/sequel-activerecord_connection/jobs/692255004)
>  
> with jruby and rails 5.1/5.0, which are failing for postgresql, due to a 
> missing method in the adapter.
>
> I had a quick look at the code, and this method is defined only in 
> lib/sequel/adapters/postgres.rb , which AFAIK isn't used in the 
> jdbc-postgresql case, although the method is called there.
>
> Can it be that the method needs to be redefined for the jdbc postgres 
> adapter as well?
>
> [This](
> https://github.com/jruby/activerecord-jdbc-adapter/blob/512433cdb62ebe5a4af4e3c4637c65acd0751801/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java)
>  
> might explain why the builds are passing for rails 6/5.2 (i.e. the method 
> has been defined in the adapter).
>

This is a method in the PostgreSQL JDBC driver API: 
https://jdbc.postgresql.org/development/privateapi/org/postgresql/jdbc/PgConnection.html#escapeString-java.lang.String-.
  
It's defined as escapeString, but JRuby converts the escape_string call to 
escapeString as part of it's convention for calling methods defined in 
Java.  I'm not sure why it isn't working in your case, but maybe 
ActiveRecord is wrapping the driver and not exposing it.

It's not something Sequel can define correctly, it needs driver support to 
do so.  The definition in the postgres adapter is only used if using 
postgres-pr, and there can be cases where it doesn't work.  You can take 
the same approach using the JDBC driver if for some reason your JDBC driver 
does not define it:

  DB.connect("jdbc:postgresql://...", :after_connect=>proc{|c| def 
c.escape_string(s) s.gsub("'", "''"); end})

In the future, please report sequel-activerecord_connection issues and 
questions to https://github.com/janko/sequel-activerecord_connection/issues.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/7cc5768b-2500-4c46-8f63-81e5956d25c7%40googlegroups.com.

Reply via email to