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 +8 -8
- data/CHANGELOG.rdoc +5 -0
- data/VERSION +1 -1
- data/directiverecord.gemspec +2 -0
- data/lib/directive_record/query/big_query.rb +0 -4
- data/lib/directive_record/query/mysql.rb +0 -4
- data/lib/directive_record/query/sql.rb +8 -21
- data/lib/directive_record/version.rb +1 -1
- data/test/unit/query/test_mysql.rb +1 -2
- data/test/unit/query/test_sql.rb +0 -8
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmViNTQwODFjYWQxNThmMzJjYzg0NzI1YjEwMzI3NmU1YzhiYjA1ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTJjNzVlZDY1YzRmZTQ0NTc5M2VlZDkyYjQ5YWVlZWZlMjhmMGNjMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDZjZjQ1NGFhMzUwNzUyMzJlMzU0MzQwNGQ3YTQzYTQ5NTQyYWE2ZWFhMDI4
|
10
|
+
NzZlNTgxYjE4OTAxMzJmZTZhN2UzOTRiZmIyODU3NWQwYzc4Y2M3YWM2MzA0
|
11
|
+
NzA3OTA0MjE3ZTVhOGFiNzM3ZTIwOTU1NzZmNDU3ZjNhYTkxNzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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.
|
1
|
+
0.1.5
|
data/directiverecord.gemspec
CHANGED
@@ -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"
|
@@ -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
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
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!
|
@@ -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}
|
158
|
+
OrderDetail.to_qry("price_each", :aggregates => {"price_each" => :sum})
|
160
159
|
)
|
161
160
|
|
162
161
|
assert_equal(
|
data/test/unit/query/test_sql.rb
CHANGED
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
|
+
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-
|
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: []
|