mochigome 0.1.2 → 0.1.3
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.
- data/lib/data_node.rb +2 -2
- data/lib/mochigome_ver.rb +1 -1
- data/lib/model_graph.rb +2 -2
- data/lib/query.rb +6 -7
- data/test/unit/data_node_test.rb +2 -2
- data/test/unit/query_test.rb +11 -0
- metadata +4 -4
data/lib/data_node.rb
CHANGED
data/lib/mochigome_ver.rb
CHANGED
data/lib/model_graph.rb
CHANGED
@@ -29,10 +29,10 @@ module Mochigome
|
|
29
29
|
r
|
30
30
|
end
|
31
31
|
|
32
|
-
def relation_over_path(path
|
32
|
+
def relation_over_path(path)
|
33
33
|
real_path = path.map(&:to_real_model).uniq
|
34
34
|
# Project ensures that we return a Rel, not a Table, even if path is empty
|
35
|
-
rel
|
35
|
+
rel = real_path.first.arel_table.project
|
36
36
|
(0..(real_path.size-2)).each do |i|
|
37
37
|
rel = relation_func(real_path[i], real_path[i+1]).call(rel)
|
38
38
|
end
|
data/lib/query.rb
CHANGED
@@ -87,7 +87,7 @@ module Mochigome
|
|
87
87
|
eos
|
88
88
|
root.comment.gsub!(/(\n|^) +/, "\\1")
|
89
89
|
|
90
|
-
r = @ids_rel.
|
90
|
+
r = @ids_rel.clone
|
91
91
|
r.apply_condition(cond)
|
92
92
|
ids_table = @layer_types.first.connection.select_all(r.to_sql)
|
93
93
|
fill_layers(ids_table, {[] => root}, @layer_types)
|
@@ -124,9 +124,9 @@ module Mochigome
|
|
124
124
|
dn[:internal_type] = model.name
|
125
125
|
|
126
126
|
cur_to_parent.fetch(obj.id).each do |parent_ids_seq|
|
127
|
-
|
128
|
-
parents.fetch(parent_ids_seq) <<
|
129
|
-
layer[parent_ids_seq + [obj.id]] =
|
127
|
+
cloned = dn.clone
|
128
|
+
parents.fetch(parent_ids_seq) << cloned
|
129
|
+
layer[parent_ids_seq + [obj.id]] = cloned
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -218,9 +218,8 @@ module Mochigome
|
|
218
218
|
|
219
219
|
def clone
|
220
220
|
c = super
|
221
|
-
c.instance_variable_set :@
|
222
|
-
c.instance_variable_set :@
|
223
|
-
c.instance_variable_set :@rel, @rel.project
|
221
|
+
c.instance_variable_set :@models, @models.clone
|
222
|
+
c.instance_variable_set :@rel, @rel.clone
|
224
223
|
c
|
225
224
|
end
|
226
225
|
|
data/test/unit/data_node_test.rb
CHANGED
@@ -16,9 +16,9 @@ describe Mochigome::DataNode do
|
|
16
16
|
assert_equal "bar", datanode.name
|
17
17
|
end
|
18
18
|
|
19
|
-
it "can be
|
19
|
+
it "can be cloned deeply" do
|
20
20
|
datanode = Mochigome::DataNode.new(:foo, :bar)
|
21
|
-
twin = datanode.
|
21
|
+
twin = datanode.clone
|
22
22
|
datanode << Mochigome::DataNode.new(:xyzzy, :froboz)
|
23
23
|
assert_empty twin.children
|
24
24
|
datanode.name = "Mike"
|
data/test/unit/query_test.rb
CHANGED
@@ -386,6 +386,17 @@ describe Mochigome::Query do
|
|
386
386
|
data_node['Products sum price']
|
387
387
|
end
|
388
388
|
|
389
|
+
it "allows grouping and aggregation on same class with another condition" do
|
390
|
+
# This query is a pointless use of aggregates, but it still shouldn't
|
391
|
+
# crash, which it has when similar queries were ran in JSAS.
|
392
|
+
q = Mochigome::Query.new(
|
393
|
+
[Product],
|
394
|
+
:aggregate_sources => [Product]
|
395
|
+
)
|
396
|
+
data_node = q.run([@store_x])
|
397
|
+
assert_equal 1, data_node["Expensive products"]
|
398
|
+
end
|
399
|
+
|
389
400
|
it "does not include hidden aggregation fields in output" do
|
390
401
|
q = Mochigome::Query.new(
|
391
402
|
[Owner, Store],
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mochigome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Mike Simon
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-17 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|