Commit e4c28d0c17614922e65fc03a91ea445014e771be
1 parent
f514b843
Exists in
master
and in
8 other branches
Fixes for mysql adapter
Showing
2 changed files
with
6 additions
and
1 deletions
Show diff stats
lib/groupdate/magic.rb
... | ... | @@ -85,6 +85,10 @@ module Groupdate |
85 | 85 | raise "Connection adapter not supported: #{adapter_name}" |
86 | 86 | end |
87 | 87 | |
88 | + if adapter_name == "MySQL" && field == :week | |
89 | + query[0] = "CAST(#{query[0]} AS DATETIME)" | |
90 | + end | |
91 | + | |
88 | 92 | group = relation.group(Groupdate::OrderHack.new(relation.send(:sanitize_sql_array, query), field, time_zone)) |
89 | 93 | if options[:series] == false |
90 | 94 | group |
... | ... | @@ -126,7 +130,7 @@ module Groupdate |
126 | 130 | lambda { |k| k.to_i } |
127 | 131 | else |
128 | 132 | utc = ActiveSupport::TimeZone["UTC"] |
129 | - lambda { |k| (k.is_a?(String) ? utc.parse(k) : k.to_time).in_time_zone(time_zone) } | |
133 | + lambda { |k| (k.is_a?(String) ? utc.parse(k) : (k.is_a?(BigDecimal) ? Time.at(k) : k.to_time)).in_time_zone(time_zone) } | |
130 | 134 | end |
131 | 135 | |
132 | 136 | count = | ... | ... |
test/test_helper.rb