Module: DuckDBConverterTimestampMonkeyPatch
- Defined in:
- lib/active_record/connection_adapters/duckdb/timestamp_monkey_patch.rb
Overview
Monkey patch DuckDB::Converter to respect ActiveRecord.default_timezone. Based on: https://github.com/suketa/ruby-duckdb/blob/master/lib/duckdb/converter.rb Change: Use Time.utc instead of Time.local when ActiveRecord.default_timezone is :utc This fixes an issue where timestamps are interpreted in local timezone instead of UTC.
Run bin/verify_timestamp_patch to test compatibility with new versions.
Constant Summary collapse
- TESTED_VERSION_MIN =
Version range verified by bin/verify_timestamp_patch
'1.0.0.0'- TESTED_VERSION_MAX =
'1.5.4.0'- EXPECTED_METHODS =
{ _to_time: { arity: 7 }, _to_time_from_duckdb_time: { arity: 4 }, _to_time_from_duckdb_timestamp_s: { arity: 1 }, _to_time_from_duckdb_timestamp_ms: { arity: 1 }, _to_time_from_duckdb_timestamp_ns: { arity: 1 } }.freeze
Class Method Summary collapse
Class Method Details
.apply_patch ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_record/connection_adapters/duckdb/timestamp_monkey_patch.rb', line 23 def apply_patch const = find_const verify_methods!(const) unless duckdb_version_ok? version = Gem.loaded_specs['duckdb']&.version puts "WARNING: duckdb gem version #{version} is outside tested range " \ "(#{TESTED_VERSION_MIN} - #{TESTED_VERSION_MAX}). " \ 'Please run bin/verify_timestamp_patch and update the range if compatible.' end const.singleton_class.prepend(ClassMethods) end |