Commit 1eaa924fe4cdb7d13802a4693ccbfcb64550b6ce
1 parent
dd4dc5da
Exists in
sqlite
adapter -> SQLite [skip ci]
Showing
1 changed file
with
5 additions
and
7 deletions
Show diff stats
lib/groupdate/magic.rb
@@ -78,9 +78,9 @@ module Groupdate | @@ -78,9 +78,9 @@ module Groupdate | ||
78 | ["(DATE_TRUNC('#{field}', (#{column}::timestamptz - INTERVAL '#{day_start} second') AT TIME ZONE ?) + INTERVAL '#{day_start} second') AT TIME ZONE ?", time_zone, time_zone] | 78 | ["(DATE_TRUNC('#{field}', (#{column}::timestamptz - INTERVAL '#{day_start} second') AT TIME ZONE ?) + INTERVAL '#{day_start} second') AT TIME ZONE ?", time_zone, time_zone] |
79 | end | 79 | end |
80 | when "SQLite" | 80 | when "SQLite" |
81 | - raise Groupdate::Error, "Time zones not supported for adapter" unless self.time_zone.utc_offset.zero? | ||
82 | - raise Groupdate::Error, "day_start not supported for adapter" unless day_start.zero? | ||
83 | - raise Groupdate::Error, "week_start not supported for adapter" unless week_start == 6 | 81 | + raise Groupdate::Error, "Time zones not supported for SQLite" unless self.time_zone.utc_offset.zero? |
82 | + raise Groupdate::Error, "day_start not supported for SQLite" unless day_start.zero? | ||
83 | + raise Groupdate::Error, "week_start not supported for SQLite" unless week_start == 6 | ||
84 | 84 | ||
85 | if field == :week | 85 | if field == :week |
86 | ["strftime('%%Y-%%m-%%d 00:00:00 UTC', #{column}, '-6 days', 'weekday 0')"] | 86 | ["strftime('%%Y-%%m-%%d 00:00:00 UTC', #{column}, '-6 days', 'weekday 0')"] |
@@ -106,11 +106,9 @@ module Groupdate | @@ -106,11 +106,9 @@ module Groupdate | ||
106 | when :month | 106 | when :month |
107 | "%Y-%m-01 00:00:00 UTC" | 107 | "%Y-%m-01 00:00:00 UTC" |
108 | when :quarter | 108 | when :quarter |
109 | - raise Groupdate::Error, "Quarter not supported for adapter" | ||
110 | - when :year | 109 | + raise Groupdate::Error, "Quarter not supported for SQLite" |
110 | + else # year | ||
111 | "%Y-01-01 00:00:00 UTC" | 111 | "%Y-01-01 00:00:00 UTC" |
112 | - else | ||
113 | - raise Groupdate::Error, "Unrecognized grouping: #{field}." | ||
114 | end | 112 | end |
115 | 113 | ||
116 | ["strftime('#{format.gsub(/%/, '%%')}', #{column})"] | 114 | ["strftime('#{format.gsub(/%/, '%%')}', #{column})"] |