diff --git a/CHANGELOG.md b/CHANGELOG.md index e4dcbfd7..adeb9f20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### Version 0.3.4 (Jun 28, 2019) + + * Fix DateTime sql format without microseconds for Rails 5.2 + * Support ssl connection + * Migration support + * Rake tasks for create / drop database + ### Version 0.3.0 (Nov 27, 2018) * Support materialized view diff --git a/clickhouse-activerecord.gemspec b/clickhouse-activerecord.gemspec index caa4efb8..95a55df6 100644 --- a/clickhouse-activerecord.gemspec +++ b/clickhouse-activerecord.gemspec @@ -23,11 +23,11 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.add_dependency "bundler", ">= 1.13.4" - spec.add_dependency 'activerecord', '>= 5.2' + spec.add_runtime_dependency 'bundler', '~> 1.13', '>= 1.13.4' + spec.add_runtime_dependency 'activerecord', '~> 5.2' spec.add_development_dependency 'bundler', '~> 1.15' spec.add_development_dependency 'rake', '~> 10.0' - spec.add_development_dependency 'rspec' - spec.add_development_dependency 'pry' + spec.add_development_dependency 'rspec', '~> 3.4' + spec.add_development_dependency 'pry', '~> 0.12' end diff --git a/lib/active_record/connection_adapters/clickhouse/oid/date_time.rb b/lib/active_record/connection_adapters/clickhouse/oid/date_time.rb index 26fc1be0..82232810 100644 --- a/lib/active_record/connection_adapters/clickhouse/oid/date_time.rb +++ b/lib/active_record/connection_adapters/clickhouse/oid/date_time.rb @@ -8,7 +8,7 @@ class DateTime < Type::DateTime # :nodoc: def serialize(value) value = super - return value unless value.acts_like?(:time) + return value.strftime('%Y-%m-%d %H:%M:%S') unless value.acts_like?(:time) value.to_time.strftime('%Y-%m-%d %H:%M:%S') end diff --git a/lib/active_record/connection_adapters/clickhouse_adapter.rb b/lib/active_record/connection_adapters/clickhouse_adapter.rb index 51a54af7..6d1d58ed 100644 --- a/lib/active_record/connection_adapters/clickhouse_adapter.rb +++ b/lib/active_record/connection_adapters/clickhouse_adapter.rb @@ -117,6 +117,19 @@ def initialize_type_map(m) # :nodoc: register_class_with_limit m, %r(Int64), Type::Integer end + # Quoting time without microseconds + def quoted_date(value) + if value.acts_like?(:time) + zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal + + if value.respond_to?(zone_conversion_method) + value = value.send(zone_conversion_method) + end + end + + value.to_s(:db) + end + # Executes insert +sql+ statement in the context of this connection using # +binds+ as the bind substitutes. +name+ is logged along with # the executed +sql+ statement. diff --git a/lib/clickhouse-activerecord/version.rb b/lib/clickhouse-activerecord/version.rb index 456211d9..2d7e77f5 100644 --- a/lib/clickhouse-activerecord/version.rb +++ b/lib/clickhouse-activerecord/version.rb @@ -1,3 +1,3 @@ module ClickhouseActiverecord - VERSION = '0.3.3' + VERSION = '0.3.4' end