0

I have a non Rails app with ActiveRecord, MySQL and jRuby. We recently upgrade from activerecord 4 to 5, and we start to having this issue:

jruby-9.2.7.0 :018 > ActiveRecord::Base.default_timezone
 => :utc

jruby-9.2.7.0 :013 > date = Time.now
 => 2020-05-08 16:37:01 -0300

jruby-9.2.7.0 :016 > Term.create(version: 'some-value', created_at: date)

D, [2020-05-08T16:37:31.440094 #62090] DEBUG -- :    (79.4ms)  BEGIN TRANSACTION
D, [2020-05-08T16:37:31.561324 #62090] DEBUG -- :   Term Create (81.9ms)  INSERT INTO `terms` (`version`, `created_at`) VALUES ('some-value', '2020-05-08 19:37:01')
D, [2020-05-08T16:37:31.725987 #62090] DEBUG -- :    (162.3ms)  COMMIT TRANSACTION

=> #<Term id: 14, version: "some-value", created_at: "2020-05-08 19:37:01">

jruby-9.2.7.0 :017 > Term.last.created_at
 => 2020-05-08 16:37:01 UTC

The expected created_at value should be 2020-05-08 19:37:01 UTC.

Any help of what could be happening is welcome :)

MorroKombat
  • 3
  • 1
  • 2
  • I tested the same example with activerecord 4 and the result is correct – MorroKombat May 08 '20 at 19:49
  • What are your timezone configurations? Maybe this answer can help to solve your problem: https://stackoverflow.com/a/32229086/1505529 – Olkin May 08 '20 at 20:32
  • I've been debugging inside the gems. As I'm using JRuby, I needed this gem for the adapter of MySQL "activerecord-jdbcmysql-adapter", and the problem seems to be in one of their dependencies. I will research more about that tomorrow that now I know where the problem is. Thanks for the help! – MorroKombat May 08 '20 at 21:23

1 Answers1

0

If anyone else is having this problem with MySQL, I fixed it with this config in the database.yml

MorroKombat
  • 3
  • 1
  • 2