directiverecord 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +8 -0
- data/VERSION +1 -1
- data/directiverecord.gemspec +1 -1
- data/lib/directive_record/gem_ext/active_record/base.rb +8 -2
- data/lib/directive_record/query.rb +5 -2
- data/lib/directive_record/query/big_query.rb +60 -0
- data/lib/directive_record/query/mysql.rb +7 -4
- data/lib/directive_record/query/sql.rb +67 -26
- data/lib/directive_record/version.rb +1 -1
- data/test/unit/gem_ext/active_record/test_base.rb +16 -1
- data/test/unit/query/test_big_query.rb +72 -0
- data/test/unit/query/test_sql.rb +2 -4
- data/test/unit/test_query.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWExODBiMTQ1NGVmYjU5MmE1ZGI4ZGE2MGI4ZWY2OWNhYjc0YWM1Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTM3ZTk5NDY0OTBiZDc5NDY1NTEyNjJjYjkyYjQ4ZTZkN2MyODUyMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGQ1MzBhNTZkZGRjZmU2ODA5OGUyNDY1NDM0NmNhYzE5YWYxYTVjYTEyMWI3
|
10
|
+
OWQ0ODhiZDVjZjY2M2RiNGYxNTgxNjVlMWVkMzMzMTZlMjM4ZGRlZDRlYzFm
|
11
|
+
Njg5YWZjOGFhZjI4NTcwZGYyYTI0NjAyZWVjZGI1YWZkYmQyZTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjFjNTE4ZmMzMWFkYjUxYzYzZDBhMmYzODA1N2FlODU3Mjg4NjFhNjI3ZDM4
|
14
|
+
ZjVhZGIyYzM3MjViMDQ4OTVmNjQwNzNlN2U4MjMyOTY1YTE3NDFiY2QzZDYw
|
15
|
+
ODBjMmMwOTQxNWI5ODAzYzE0NTNlMDg5NDRiMTUyMmRjZDBkNWI=
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
= DirectiveRecord CHANGELOG
|
2
2
|
|
3
|
+
== Version 0.1.2 (January 21, 2015)
|
4
|
+
|
5
|
+
* Downgraded ActiveRecord gem dependency to >= 3.2.13
|
6
|
+
* Being able to specify the connection to query with
|
7
|
+
* Ensuring option values to be arrays
|
8
|
+
* Not making the path delimiter obligated (which implies denormalized data)
|
9
|
+
* Added BigQuery support (denormalized data)! ^^
|
10
|
+
|
3
11
|
== Version 0.1.1 (January 19, 2015)
|
4
12
|
|
5
13
|
* Optimizing query when passing :optimize => true and having paths within the select statement
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/directiverecord.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = DirectiveRecord::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency "activerecord", ">=
|
18
|
+
gem.add_dependency "activerecord", ">= 3.2.13"
|
19
19
|
|
20
20
|
gem.add_development_dependency "rake"
|
21
21
|
gem.add_development_dependency "yard"
|
@@ -2,11 +2,17 @@ module ActiveRecord
|
|
2
2
|
class Base
|
3
3
|
|
4
4
|
def self.to_qry(*args)
|
5
|
-
DirectiveRecord::Query.new(self).to_sql(*args)
|
5
|
+
DirectiveRecord::Query.new(self, extract_connection(args)).to_sql(*args)
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.qry(*args)
|
9
|
-
|
9
|
+
extract_connection(args).select_rows to_qry(*args)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def self.extract_connection(args)
|
15
|
+
(args[-1][:connection] if args[-1].is_a?(Hash)) || connection
|
10
16
|
end
|
11
17
|
|
12
18
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require "directive_record/query/sql"
|
2
2
|
require "directive_record/query/mysql"
|
3
|
+
require "directive_record/query/big_query"
|
3
4
|
|
4
5
|
module DirectiveRecord
|
5
6
|
module Query
|
6
7
|
|
7
|
-
def self.new(klass)
|
8
|
-
class_for(klass.connection.class.name.downcase).new(klass)
|
8
|
+
def self.new(klass, connection = nil)
|
9
|
+
class_for((connection || klass.connection).class.name.downcase).new(klass)
|
9
10
|
end
|
10
11
|
|
11
12
|
private
|
@@ -13,6 +14,8 @@ module DirectiveRecord
|
|
13
14
|
def self.class_for(connection_class)
|
14
15
|
if connection_class.include?("mysql")
|
15
16
|
MySQL
|
17
|
+
elsif connection_class.include?("bigquery")
|
18
|
+
BigQuery
|
16
19
|
else
|
17
20
|
raise NotImplementedError, "Connection type not supported"
|
18
21
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module DirectiveRecord
|
2
|
+
module Query
|
3
|
+
class BigQuery < SQL
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def aggregate_delimiter
|
8
|
+
"__"
|
9
|
+
end
|
10
|
+
|
11
|
+
def group_by_all_sql
|
12
|
+
"all_rows"
|
13
|
+
end
|
14
|
+
|
15
|
+
def normalize_from!(options)
|
16
|
+
period = options[:period]
|
17
|
+
|
18
|
+
options[:where].delete_if do |statement|
|
19
|
+
if statement.match(/^#{period} = '(\d{4}-\d{2}-\d{2})'$/)
|
20
|
+
begin_date, end_date = $1, $1
|
21
|
+
elsif statement.match(/^#{period} >= '(\d{4}-\d{2}-\d{2})' AND #{period} <= '(\d{4}-\d{2}-\d{2})'$/)
|
22
|
+
begin_date, end_date = $1, $2
|
23
|
+
end
|
24
|
+
if begin_date
|
25
|
+
dataset = ::BigQuery.connection.instance_variable_get(:@dataset) # TODO: fix this
|
26
|
+
options[:from] = (Date.parse(begin_date)..Date.parse(end_date)).collect do |date|
|
27
|
+
"[#{dataset}.#{base.table_name}_#{date.strftime("%Y%m%d")}]"
|
28
|
+
end
|
29
|
+
options[:from] = "\n #{options[:from].join(",\n ")}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def prepend_base_alias!(options); end
|
35
|
+
|
36
|
+
def finalize_options!(options)
|
37
|
+
aliases = options[:aliases] || {}
|
38
|
+
|
39
|
+
options[:select].collect! do |string|
|
40
|
+
expression, select_alias = string.match(/^(.*) AS (.*)$/).try(:captures)
|
41
|
+
if select_alias
|
42
|
+
aliases[expression] = select_alias
|
43
|
+
options[:group_by].to_s.include?(expression) || !expression.match(/^\w+(\.\w+)*$/) ? string : "MAX(#{expression}) AS #{select_alias}"
|
44
|
+
else
|
45
|
+
string.match(/^\w+(\.\w+)*$/) ? "MAX(#{string})" : string
|
46
|
+
end
|
47
|
+
end if options[:group_by]
|
48
|
+
|
49
|
+
[:group_by, :having, :order_by].each do |key|
|
50
|
+
if value = options[key]
|
51
|
+
value = value.join ", "
|
52
|
+
aliases.each{|pattern, replacement| value.gsub! pattern, replacement}
|
53
|
+
options[key] = value
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -22,11 +22,14 @@ module DirectiveRecord
|
|
22
22
|
|
23
23
|
def finalize_options!(options)
|
24
24
|
return unless options[:numerize_aliases]
|
25
|
+
|
26
|
+
aliases = options[:aliases] || {}
|
27
|
+
|
25
28
|
[:group_by, :having, :order_by].each do |key|
|
26
|
-
if
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
if value = options[key]
|
30
|
+
value = value.join ", "
|
31
|
+
aliases.each{|pattern, replacement| value.gsub! pattern, replacement}
|
32
|
+
options[key] = value
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
@@ -7,9 +7,10 @@ module DirectiveRecord
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def to_sql(*args)
|
10
|
-
options =
|
10
|
+
options = to_options(args)
|
11
11
|
validate_options! options
|
12
12
|
|
13
|
+
check_path_delimiter! options
|
13
14
|
optimize_query! options
|
14
15
|
|
15
16
|
prepare_options! options
|
@@ -20,14 +21,13 @@ module DirectiveRecord
|
|
20
21
|
prepend_base_alias! options
|
21
22
|
finalize_options! options
|
22
23
|
|
24
|
+
flatten_options! options
|
23
25
|
compose_sql options
|
24
26
|
end
|
25
27
|
|
26
28
|
private
|
27
29
|
|
28
|
-
def path_delimiter
|
29
|
-
raise NotImplementedError
|
30
|
-
end
|
30
|
+
def path_delimiter; end
|
31
31
|
|
32
32
|
def aggregate_delimiter
|
33
33
|
raise NotImplementedError
|
@@ -57,18 +57,25 @@ module DirectiveRecord
|
|
57
57
|
sql_alias
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
60
|
+
def to_options(args)
|
61
61
|
options = args.extract_options!.deep_dup
|
62
62
|
options.reverse_merge! :select => (args.empty? ? "*" : args)
|
63
|
+
|
64
|
+
[:select, :where, :group_by, :order_by].each do |key|
|
65
|
+
if value = options[key]
|
66
|
+
options[key] = [value].flatten
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
63
70
|
options
|
64
71
|
end
|
65
72
|
|
66
73
|
def validate_options!(options)
|
67
|
-
options.assert_valid_keys :select, :where, :group_by, :order_by, :limit, :offset, :aggregates, :numerize_aliases, :optimize
|
74
|
+
options.assert_valid_keys :connection, :select, :where, :group_by, :order_by, :limit, :offset, :aggregates, :numerize_aliases, :period, :optimize
|
68
75
|
end
|
69
76
|
|
70
77
|
def optimize_query!(options)
|
71
|
-
select =
|
78
|
+
select = options[:select]
|
72
79
|
if options[:optimize] && (select != %w(id)) && select.any?{|x| x.match(/^\w+(\.\w+)+$/)}
|
73
80
|
ids = base.connection.select_values(to_sql(options.merge(:select => "id"))).uniq + [0]
|
74
81
|
options[:where] = ["id IN (#{ids.join(", ")})"]
|
@@ -77,10 +84,26 @@ module DirectiveRecord
|
|
77
84
|
end
|
78
85
|
end
|
79
86
|
|
87
|
+
def check_path_delimiter!(options)
|
88
|
+
unless path_delimiter
|
89
|
+
normalize_group_by! options
|
90
|
+
[:select, :where, :having, :group_by, :order_by].each do |key|
|
91
|
+
if value = options[key]
|
92
|
+
value.collect! do |val|
|
93
|
+
base.reflections.keys.inject(val) do |v, association|
|
94
|
+
v.gsub(/\b#{association}\.([a-z_\.]+)/) { "#{association}_#{$1.gsub(".", "_")}" }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
80
102
|
def prepare_options!(options); end
|
81
103
|
|
82
104
|
def normalize_options!(options)
|
83
105
|
normalize_select!(options)
|
106
|
+
normalize_from!(options)
|
84
107
|
normalize_where!(options)
|
85
108
|
normalize_group_by!(options)
|
86
109
|
normalize_order_by!(options)
|
@@ -88,10 +111,9 @@ module DirectiveRecord
|
|
88
111
|
end
|
89
112
|
|
90
113
|
def normalize_select!(options)
|
91
|
-
|
92
|
-
select.uniq!
|
114
|
+
options[:select].uniq!
|
93
115
|
|
94
|
-
options[:scales] = select.inject({}) do |hash, sql|
|
116
|
+
options[:scales] = options[:select].inject({}) do |hash, sql|
|
95
117
|
if scale = column_for(sql).try(:scale)
|
96
118
|
hash[sql] = scale
|
97
119
|
end
|
@@ -117,15 +139,21 @@ module DirectiveRecord
|
|
117
139
|
sql_alias = options[:aliases][prepend_base_alias(sql_alias || sql)] = "c#{array.size + 1}"
|
118
140
|
end
|
119
141
|
|
142
|
+
options[:aliases][sql] = sql_alias if sql_alias
|
143
|
+
|
120
144
|
array << [sql, sql_alias].compact.join(" AS ")
|
121
145
|
array
|
122
146
|
end
|
123
147
|
end
|
124
148
|
|
149
|
+
def normalize_from!(options)
|
150
|
+
options[:from] = "#{base.table_name} #{base_alias}"
|
151
|
+
end
|
152
|
+
|
125
153
|
def normalize_where!(options)
|
126
154
|
regexp = /^\S+/
|
127
155
|
|
128
|
-
where, having = (
|
156
|
+
where, having = (options[:where] || []).partition do |statement|
|
129
157
|
!options[:aggregated].keys.include?(statement.strip.match(regexp).to_s) &&
|
130
158
|
statement.downcase.gsub(/((?<![\\])['"])((?:.(?!(?<![\\])\1))*.?)\1/, " ")
|
131
159
|
.scan(/([a-zA-Z_\.]+)?\s*(=|<=>|>=|>|<=|<|<>|!=|is|like|rlike|regexp|in|between|not|sounds|soundex)(\b|\s)/)
|
@@ -144,23 +172,27 @@ module DirectiveRecord
|
|
144
172
|
end
|
145
173
|
|
146
174
|
[:where, :having].each do |key|
|
147
|
-
|
148
|
-
|
175
|
+
if options[key].empty?
|
176
|
+
options.delete key
|
177
|
+
end
|
149
178
|
end
|
150
179
|
end
|
151
180
|
|
152
181
|
def normalize_group_by!(options)
|
153
|
-
group_by =
|
154
|
-
|
182
|
+
if (group_by = options[:group_by]) == [:all]
|
183
|
+
group_by.replace [group_by_all_sql]
|
184
|
+
end
|
155
185
|
end
|
156
186
|
|
157
187
|
def normalize_order_by!(options)
|
158
188
|
options[:order_by] ||= (options[:group_by] || []).collect do |path|
|
159
189
|
direction = "DESC" if path.to_s == "date"
|
160
190
|
"#{path} #{direction}".strip
|
161
|
-
end
|
191
|
+
end unless options[:select] == "COUNT(*)"
|
192
|
+
|
193
|
+
return unless options[:order_by]
|
162
194
|
|
163
|
-
|
195
|
+
options[:order_by].collect! do |x|
|
164
196
|
segments = x.split " "
|
165
197
|
direction = segments.pop if %w(asc desc).include?(segments[-1].downcase)
|
166
198
|
path = segments.join " "
|
@@ -181,12 +213,6 @@ module DirectiveRecord
|
|
181
213
|
options[:order_by].compact!
|
182
214
|
end
|
183
215
|
|
184
|
-
def to_array!(options, key)
|
185
|
-
if value = options[key]
|
186
|
-
options[key] = [value].flatten
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
216
|
def column_for(path)
|
191
217
|
segments = path.split(".")
|
192
218
|
column = segments.pop
|
@@ -251,14 +277,15 @@ module DirectiveRecord
|
|
251
277
|
def prepend_base_alias!(options)
|
252
278
|
[:select, :where, :group_by, :having, :order_by].each do |key|
|
253
279
|
if value = options[key]
|
254
|
-
|
280
|
+
value.collect! do |sql|
|
281
|
+
prepend_base_alias sql, options[:aliases]
|
282
|
+
end
|
255
283
|
end
|
256
284
|
end
|
257
285
|
end
|
258
286
|
|
259
287
|
def prepend_base_alias(sql, aliases = {})
|
260
288
|
columns = base.columns_hash.keys
|
261
|
-
sql = sql.join ", " if sql.is_a?(Array)
|
262
289
|
sql.gsub(/("[^"]*"|'[^']*'|`[^`]*`|[a-zA-Z_#{aggregate_delimiter}]+(\.[a-zA-Z_\*]+)*)/) do
|
263
290
|
columns.include?($1) ? "#{base_alias}.#{$1}" : begin
|
264
291
|
if (string = $1).match /^([a-zA-Z_\.]+)\.([a-zA-Z_\*]+)$/
|
@@ -273,8 +300,22 @@ module DirectiveRecord
|
|
273
300
|
|
274
301
|
def finalize_options!(options); end
|
275
302
|
|
303
|
+
def flatten_options!(options)
|
304
|
+
[:select, :group_by, :order_by].each do |key|
|
305
|
+
if value = options[key]
|
306
|
+
options[key] = value.join(", ") if value.is_a?(Array)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
[:where, :having].each do |key|
|
311
|
+
if value = options[key]
|
312
|
+
options[key] = value.collect{|x| "(#{x})"}.join(" AND ") if value.is_a?(Array)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
276
317
|
def compose_sql(options)
|
277
|
-
sql = ["SELECT #{options[:select]}", "FROM #{
|
318
|
+
sql = ["SELECT #{options[:select]}", "FROM #{options[:from]}", options[:joins]].compact
|
278
319
|
|
279
320
|
[:where, :group_by, :having, :order_by, :limit, :offset].each do |key|
|
280
321
|
unless (value = options[key]).blank?
|
@@ -10,7 +10,7 @@ module Unit
|
|
10
10
|
it "initiates a DirectiveRecord::Query instance and returns the query SQL" do
|
11
11
|
query = mock
|
12
12
|
query.expects(:to_sql).with(:select => "city").returns("SELECT city FROM offices")
|
13
|
-
DirectiveRecord::Query.expects(:new).with(Office).returns(query)
|
13
|
+
DirectiveRecord::Query.expects(:new).with(Office, Office.connection).returns(query)
|
14
14
|
assert_equal "SELECT city FROM offices", Office.to_qry(:select => "city")
|
15
15
|
end
|
16
16
|
end
|
@@ -22,6 +22,21 @@ module Unit
|
|
22
22
|
assert_equal %w(NYC), Office.qry("city")
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
describe ".extract_connection" do
|
27
|
+
describe "when specified" do
|
28
|
+
it "returns the connection" do
|
29
|
+
assert_equal "connection", Office.send(:extract_connection, ["id", "name", {:connection => "connection"}])
|
30
|
+
assert_equal "connection", Office.send(:extract_connection, [{:connection => "connection"}])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
describe "when not specified" do
|
34
|
+
it "returns the connection of the class" do
|
35
|
+
Office.expects(:connection).returns(class_connection = "class_connection")
|
36
|
+
assert_equal class_connection, Office.send(:extract_connection, ["id", "name"])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
25
40
|
end
|
26
41
|
|
27
42
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative "../../test_helper"
|
2
|
+
|
3
|
+
module BigQuery
|
4
|
+
class Client
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module Unit
|
9
|
+
module Query
|
10
|
+
class TestBigQuery < MiniTest::Test
|
11
|
+
|
12
|
+
describe DirectiveRecord::Query::BigQuery do
|
13
|
+
before do
|
14
|
+
(connection = BigQuery::Client.new).instance_variable_set(:@dataset, "my_stats")
|
15
|
+
BigQuery.expects(:connection).returns(connection).at_least_once
|
16
|
+
end
|
17
|
+
|
18
|
+
it "generates the expected SQL" do
|
19
|
+
assert_equal(
|
20
|
+
%Q{
|
21
|
+
SELECT MAX(id),
|
22
|
+
SUM(order_details_quantity_ordered) AS sum__order_details_quantity_ordered,
|
23
|
+
SUM(order_details_price_each) AS sum__order_details_price_each,
|
24
|
+
SUM(order_details_quantity_ordered * order_details_price_each) AS price
|
25
|
+
FROM
|
26
|
+
[my_stats.orders_20150121]
|
27
|
+
GROUP BY id
|
28
|
+
ORDER BY price DESC
|
29
|
+
}.strip.gsub(/\s+/, " "),
|
30
|
+
Order.to_qry(
|
31
|
+
"id", "order_details_quantity_ordered", "order_details_price_each", "SUM(order_details_quantity_ordered * order_details_price_each) AS price",
|
32
|
+
:connection => BigQuery.connection,
|
33
|
+
:where => "order_date = '2015-01-21'",
|
34
|
+
:group_by => "id",
|
35
|
+
:order_by => "price DESC",
|
36
|
+
:period => "order_date",
|
37
|
+
:aggregates => {
|
38
|
+
"order_details_quantity_ordered" => :sum,
|
39
|
+
"order_details_price_each" => :sum
|
40
|
+
}
|
41
|
+
).strip.gsub(/\s+/, " ")
|
42
|
+
)
|
43
|
+
|
44
|
+
assert_equal(
|
45
|
+
%Q{
|
46
|
+
SELECT MAX(id), SUM(order_details_quantity_ordered * order_details_price_each)
|
47
|
+
FROM
|
48
|
+
[my_stats.orders_20150115],
|
49
|
+
[my_stats.orders_20150116],
|
50
|
+
[my_stats.orders_20150117],
|
51
|
+
[my_stats.orders_20150118],
|
52
|
+
[my_stats.orders_20150119],
|
53
|
+
[my_stats.orders_20150120],
|
54
|
+
[my_stats.orders_20150121]
|
55
|
+
GROUP BY id
|
56
|
+
ORDER BY id
|
57
|
+
}.strip.gsub(/\s+/, " "),
|
58
|
+
Order.to_qry(
|
59
|
+
"id", "SUM(order_details.quantity_ordered * order_details.price_each)",
|
60
|
+
:connection => BigQuery.connection,
|
61
|
+
:where => "order_date >= '2015-01-15' AND order_date <= '2015-01-21'",
|
62
|
+
:group_by => "id",
|
63
|
+
:order_by => "id",
|
64
|
+
:period => "order_date"
|
65
|
+
).strip.gsub(/\s+/, " ")
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/test/unit/query/test_sql.rb
CHANGED
@@ -17,10 +17,8 @@ module Unit
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#path_delimiter" do
|
20
|
-
it "
|
21
|
-
|
22
|
-
@directive_query.send :path_delimiter
|
23
|
-
end
|
20
|
+
it "returns nil" do
|
21
|
+
assert_nil @directive_query.send(:path_delimiter)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
data/test/unit/test_query.rb
CHANGED
@@ -7,7 +7,7 @@ module Unit
|
|
7
7
|
describe ".new" do
|
8
8
|
it "returns the appropriate query instance" do
|
9
9
|
instance = mock
|
10
|
-
instance.expects(:new).with(Office).returns("SELECT * FROM offices")
|
10
|
+
instance.expects(:new).with(Office, nil).returns("SELECT * FROM offices")
|
11
11
|
DirectiveRecord::Query.expects(:class_for).with("activerecord::connectionadapters::mysql2adapter").returns(instance)
|
12
12
|
assert_equal "SELECT * FROM offices", DirectiveRecord::Query.new(Office)
|
13
13
|
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
|
+
version: 0.1.2
|
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-
|
11
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.2.13
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.2.13
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/directive_record/gem_ext/active_record/base.rb
|
144
144
|
- lib/directive_record/gem_ext/active_record/relation.rb
|
145
145
|
- lib/directive_record/query.rb
|
146
|
+
- lib/directive_record/query/big_query.rb
|
146
147
|
- lib/directive_record/query/mysql.rb
|
147
148
|
- lib/directive_record/query/sql.rb
|
148
149
|
- lib/directive_record/relation.rb
|
@@ -164,6 +165,7 @@ files:
|
|
164
165
|
- test/test_helper/coverage.rb
|
165
166
|
- test/unit/gem_ext/active_record/test_base.rb
|
166
167
|
- test/unit/gem_ext/active_record/test_relation.rb
|
168
|
+
- test/unit/query/test_big_query.rb
|
167
169
|
- test/unit/query/test_mysql.rb
|
168
170
|
- test/unit/query/test_sql.rb
|
169
171
|
- test/unit/test_directive_record.rb
|
@@ -210,6 +212,7 @@ test_files:
|
|
210
212
|
- test/test_helper/coverage.rb
|
211
213
|
- test/unit/gem_ext/active_record/test_base.rb
|
212
214
|
- test/unit/gem_ext/active_record/test_relation.rb
|
215
|
+
- test/unit/query/test_big_query.rb
|
213
216
|
- test/unit/query/test_mysql.rb
|
214
217
|
- test/unit/query/test_sql.rb
|
215
218
|
- test/unit/test_directive_record.rb
|