activerecord 4.2.11.1
activerecord-jdbc-adapter 1.3.25
activerecord-jdbcpostgresql-adapter 1.3.25
jdbc-postgres 9.4.1206
The following method call returns a Date when using ruby 2.3.3 but returns a String when using JRuby-9.1.17.0 with activerecord-jdbcpostgresql-adapter :
2.3.3 :017 > Table.select('now() as date').first.date
Table Load (0.7ms) SELECT now() as date FROM "tables" ORDER BY "tables"."id" ASC LIMIT 1
=> 2019-05-17 03:46:52 UTC
jruby-9.1.17.0 :002 > Table.select('now() as date').first.date
Table Load (2.0ms) SELECT now() as date FROM "tables" ORDER BY "tables"."id" ASC LIMIT 1
=> "2019-05-17 03:48:57.572526+00"
This only happens if the selected attribute does not exist in the database:
2.3.3 :012 > Table.select(:created_at).first.created_at
Table Load (0.6ms) SELECT "tables"."created_at" FROM "tables" ORDER BY "tables"."id" ASC LIMIT 1
=> Wed, 25 Sep 2013 14:26:17 -03 -03:00
jruby-9.1.17.0 :019 > Table.select(:created_at).first.created_at
Table Load (0.8ms) SELECT "tables"."created_at" FROM "tables" ORDER BY "tables"."id" ASC LIMIT 1
=> Wed, 25 Sep 2013 14:26:17 -03 -03:00
This happens with either WebRick or Tomcat 7. This error does not occur with the same version of activerecord-jdbc-adapter if using Active Record 4.0 or 4.1. Upgrading to latest jruby-9.2.7.0 did not help either.
seems like a compatibility bug in AR-JDBC, at this point likely a won't fix as AR 4.2 also isn't supported.
you should try upgrading to 5.x if this is an issue or try resolving the problem and submit a PR ...
as a last resort try setting
ActiveRecord::ConnectionAdapters::JdbcConnection.raw_date_time = true(altough I think its alreadytruewhen running on AR 4.2)