directiverecord 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2MxYzVmZWI5YjQxYWI0YjMwZTY2NDQzNWQwN2RiZTk4YzU4YjYxMQ==
4
+ MmViNTQwODFjYWQxNThmMzJjYzg0NzI1YjEwMzI3NmU1YzhiYjA1ZA==
5
5
  data.tar.gz: !binary |-
6
- OGNkNWI1NTdiMDg4MGNkZWU1MjBkNTAwMDg5Zjg1OGUzOGE4NzI4ZQ==
6
+ ZTJjNzVlZDY1YzRmZTQ0NTc5M2VlZDkyYjQ5YWVlZWZlMjhmMGNjMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmI5MGE4ZDBhNDNkZDYzMmU2ZTkzNmZmNTA1NDZlZjhmMDg2OGY4OGQ0ODk4
10
- YTA1NGE1NGNkYjExYTM5OTkzNTA2NmU2ZTYyODVhMmQ3MjhkMGUxNDUzNTJj
11
- ZjUxYWE0ZmEyMzA3MzZhYjgyZWM5NThkMmQwZjlkYjMzYmE0ZDM=
9
+ ZDZjZjQ1NGFhMzUwNzUyMzJlMzU0MzQwNGQ3YTQzYTQ5NTQyYWE2ZWFhMDI4
10
+ NzZlNTgxYjE4OTAxMzJmZTZhN2UzOTRiZmIyODU3NWQwYzc4Y2M3YWM2MzA0
11
+ NzA3OTA0MjE3ZTVhOGFiNzM3ZTIwOTU1NzZmNDU3ZjNhYTkxNzk=
12
12
  data.tar.gz: !binary |-
13
- Y2UwZGM3YTA2NDdmYTAzNTg5Yzk3Y2FmOTZiZTMzYzhlOTM0OTczZGM1ODg2
14
- YTRiZThhODFiOTA4NDBmMWYyYzdhNDc2Mjg2NjRiODE3MDVmYmM1YjlkYzI3
15
- NzQ2YmMyNDZmNDgzMjE5NGZjMjk4ZjJlN2U1NTFkYmRiZjYwYzI=
13
+ MWQwZWM4NDU1ZmFiZDlkYmE5NDY4ZTZiYmIwNTM2NTI1Mjk1NjhjNjIxNDZi
14
+ YjI2N2JjOGY5NDUyZDllZGZiMTMxMzI4ODc2Y2I2NGIwZDVmYzkyOGNkYzdl
15
+ ODYwOTY4Y2QzNDRhZTg1MmU1Mzk1NWQyNDI4MTAzODE1NzU2NGE=
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,10 @@
1
1
  = DirectiveRecord CHANGELOG
2
2
 
3
+ == Version 0.1.5 (February 11, 2015)
4
+
5
+ * Dropped :group_by => :all option
6
+ * Locked Arel gem dependency to “< 6.0.0”
7
+
3
8
  == Version 0.1.4 (January 22, 2015)
4
9
 
5
10
  * Improved partitioning conditions to WHERE or HAVING which fixes conditions with non-aggregate functions (e.g. LOWER)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -14,8 +14,10 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "directiverecord"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = DirectiveRecord::VERSION
17
+ gem.licenses = ["MIT"]
17
18
 
18
19
  gem.add_dependency "activerecord", ">= 3.2.13"
20
+ gem.add_dependency "arel", "< 6.0.0"
19
21
 
20
22
  gem.add_development_dependency "rake"
21
23
  gem.add_development_dependency "yard"
@@ -8,10 +8,6 @@ module DirectiveRecord
8
8
  "__"
9
9
  end
10
10
 
11
- def group_by_all_sql
12
- "all_rows"
13
- end
14
-
15
11
  def normalize_from!(options)
16
12
  period = options[:period]
17
13
 
@@ -12,10 +12,6 @@ module DirectiveRecord
12
12
  ":"
13
13
  end
14
14
 
15
- def group_by_all_sql
16
- "NULL"
17
- end
18
-
19
15
  def quote_alias(sql_alias)
20
16
  "`#{sql_alias}`"
21
17
  end
@@ -50,10 +50,6 @@ SQL
50
50
  raise NotImplementedError
51
51
  end
52
52
 
53
- def group_by_all_sql
54
- raise NotImplementedError
55
- end
56
-
57
53
  def select_aggregate_sql(method, path)
58
54
  "#{method.to_s.upcase}(#{path})"
59
55
  end
@@ -103,7 +99,6 @@ SQL
103
99
 
104
100
  def check_path_delimiter!(options)
105
101
  unless path_delimiter
106
- normalize_group_by! options
107
102
  [:select, :where, :having, :group_by, :order_by].each do |key|
108
103
  if value = options[key]
109
104
  value.collect! do |val|
@@ -122,7 +117,6 @@ SQL
122
117
  normalize_select!(options)
123
118
  normalize_from!(options)
124
119
  normalize_where!(options)
125
- normalize_group_by!(options)
126
120
  normalize_order_by!(options)
127
121
  options.reject!{|k, v| v.blank?}
128
122
  end
@@ -202,12 +196,6 @@ SQL
202
196
  end
203
197
  end
204
198
 
205
- def normalize_group_by!(options)
206
- if (group_by = options[:group_by]) == [:all]
207
- group_by.replace [group_by_all_sql]
208
- end
209
- end
210
-
211
199
  def normalize_order_by!(options)
212
200
  options[:order_by] ||= (options[:group_by] || []).collect do |path|
213
201
  direction = "DESC" if path.to_s == "date"
@@ -220,18 +208,17 @@ SQL
220
208
  segments = x.split " "
221
209
  direction = segments.pop if %w(asc desc).include?(segments[-1].downcase)
222
210
  path = segments.join " "
211
+ scale = options[:scales][path]
223
212
 
224
- if path != group_by_all_sql
225
- scale = options[:scales][path]
226
- select = begin
227
- if aggregate_method = (options[:aggregates] || {})[path]
228
- select_aggregate_sql(aggregate_method, path)
229
- else
230
- path
231
- end
213
+ select = begin
214
+ if aggregate_method = (options[:aggregates] || {})[path]
215
+ select_aggregate_sql(aggregate_method, path)
216
+ else
217
+ path
232
218
  end
233
- "#{scale ? "ROUND(#{select}, #{scale})" : select} #{direction.upcase if direction}".strip
234
219
  end
220
+
221
+ "#{scale ? "ROUND(#{select}, #{scale})" : select} #{direction.upcase if direction}".strip
235
222
  end
236
223
 
237
224
  options[:order_by].compact!
@@ -1,7 +1,7 @@
1
1
  module DirectiveRecord
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 4
4
+ TINY = 5
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
@@ -153,10 +153,9 @@ module Unit
153
153
  %Q{
154
154
  SELECT ROUND(SUM(`od`.price_each), 2) AS `sum:price_each`
155
155
  FROM order_details `od`
156
- GROUP BY NULL
157
156
  }
158
157
  ),
159
- OrderDetail.to_qry("price_each", :aggregates => {"price_each" => :sum}, :group_by => :all)
158
+ OrderDetail.to_qry("price_each", :aggregates => {"price_each" => :sum})
160
159
  )
161
160
 
162
161
  assert_equal(
@@ -29,14 +29,6 @@ module Unit
29
29
  end
30
30
  end
31
31
  end
32
-
33
- describe "#group_by_all_sql" do
34
- it "raises an NotImplementedError" do
35
- assert_raises NotImplementedError do
36
- @directive_query.send :group_by_all_sql
37
- end
38
- end
39
- end
40
32
  end
41
33
 
42
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: directiverecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Engel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-22 00:00:00.000000000 Z
11
+ date: 2015-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.13
27
+ - !ruby/object:Gem::Dependency
28
+ name: arel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - <
32
+ - !ruby/object:Gem::Version
33
+ version: 6.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - <
39
+ - !ruby/object:Gem::Version
40
+ version: 6.0.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +186,8 @@ files:
172
186
  - test/unit/test_query.rb
173
187
  - test/unit/test_relation.rb
174
188
  homepage: https://github.com/archan937/directiverecord
175
- licenses: []
189
+ licenses:
190
+ - MIT
176
191
  metadata: {}
177
192
  post_install_message:
178
193
  rdoc_options: []