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 CHANGED
@@ -41,9 +41,9 @@ module Mochigome
41
41
  @children[idx]
42
42
  end
43
43
 
44
- def dup
44
+ def clone
45
45
  twin = super
46
- twin.instance_variable_set(:@children, @children.map{|c| c.dup})
46
+ twin.instance_variable_set(:@children, @children.map{|c| c.clone})
47
47
  twin
48
48
  end
49
49
 
data/lib/mochigome_ver.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mochigome
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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, rel = nil)
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 ||= real_path.first.arel_table.project
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.dup
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
- duped = dn.dup
128
- parents.fetch(parent_ids_seq) << duped
129
- layer[parent_ids_seq + [obj.id]] = duped
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 :@spine, @spine.dup
222
- c.instance_variable_set :@models, @models.dup
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
 
@@ -16,9 +16,9 @@ describe Mochigome::DataNode do
16
16
  assert_equal "bar", datanode.name
17
17
  end
18
18
 
19
- it "can be duplicated deeply" do
19
+ it "can be cloned deeply" do
20
20
  datanode = Mochigome::DataNode.new(:foo, :bar)
21
- twin = datanode.dup
21
+ twin = datanode.clone
22
22
  datanode << Mochigome::DataNode.new(:xyzzy, :froboz)
23
23
  assert_empty twin.children
24
24
  datanode.name = "Mike"
@@ -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: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
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-12 00:00:00 Z
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