-
Notifications
You must be signed in to change notification settings - Fork 22k
Closed
Description
Steps to reproduce
For midnigh(00:00) only, the processing of the time
type in the trilogy adapter is broken.
※ An example of mysql2 is also included for reference.
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
gem "trilogy"
gem "mysql2"
end
require "active_record"
require "minitest/autorun"
require "logger"
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.establish_connection(adapter: "trilogy", database: "test", username: "root", host: '127.0.0.1', port: 3306)
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.time :time_column
end
end
class Post < ActiveRecord::Base
end
Post.create!(time_column: '00:00')
class BugTest < Minitest::Test
def test_mysql2
ActiveRecord::Base.establish_connection(adapter: "mysql2", database: "test", username: "root", host: '127.0.0.1', port: 3306)
assert_equal Post.take.time_column, Time.utc(2000, 1, 1, 0, 0)
end
def test_trilogy
ActiveRecord::Base.establish_connection(adapter: "trilogy", database: "test", username: "root", host: '127.0.0.1', port: 3306)
assert_equal Post.take.time_column, Time.utc(2000, 1, 1, 0, 0)
end
end
Expected behavior
Both mysql2
and torilogy
, 2000-01-01T00:00:00Z
to be returned.
Actual behavior
In case of trilogy
, nil
is returned.
Failure:
BugTest#test_trilogy [midnight.rb:42]:
Expected: nil
Actual: 2000-01-01 00:00:00 UTC
Is it a problem with Trilogy?
client = Trilogy.new(host: "127.0.0.1", port: 13306, username: "root")
client.change_db('test')
client.query('SELECT * FROM posts;').to_a #=> [[1, nil]]
I was wondering where to report this. activerecord-trilogy-adapter and trilogy and rails/rails.
Sorry if I am wrong.
System configuration
Rails version: v7.1.0.alpha (main@c9cdd80)
Ruby version: v3.2.2
Trilogy: v2.4.1
Metadata
Metadata
Assignees
Labels
No labels