alf-core 0.13.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +77 -0
- data/examples/operators/page.alf +4 -0
- data/lib/alf-adapter-fs/alf/adapter/folder.rb +4 -0
- data/lib/alf-adapter-fs/alf/adapter/folder/connection.rb +3 -2
- data/lib/alf-adapter/alf/adapter/connection.rb +1 -1
- data/lib/alf-algebra/alf/algebra/operand.rb +2 -2
- data/lib/alf-algebra/alf/algebra/operand/fake.rb +3 -3
- data/lib/alf-algebra/alf/algebra/operand/named.rb +1 -1
- data/lib/alf-algebra/alf/algebra/operand/proxy.rb +14 -0
- data/lib/alf-algebra/alf/algebra/operator.rb +4 -1
- data/lib/alf-algebra/alf/algebra/operator/clip.rb +7 -4
- data/lib/alf-algebra/alf/algebra/operator/frame.rb +22 -0
- data/lib/alf-algebra/alf/algebra/operator/hierarchize.rb +22 -0
- data/lib/alf-algebra/alf/algebra/operator/page.rb +22 -0
- data/lib/alf-algebra/alf/algebra/operator/project.rb +4 -9
- data/lib/alf-algebra/alf/algebra/operator/rank.rb +2 -2
- data/lib/alf-algebra/alf/algebra/support.rb +2 -0
- data/lib/alf-algebra/alf/algebra/support/signature.rb +2 -1
- data/lib/alf-algebra/alf/algebra/support/with_ordering.rb +11 -0
- data/lib/alf-core/ext/domain/heading_based.rb +16 -4
- data/lib/alf-core/facade.rb +5 -1
- data/lib/alf-core/version.rb +2 -2
- data/lib/alf-database/alf/database/connection.rb +2 -2
- data/lib/alf-database/alf/database/options.rb +0 -3
- data/lib/alf-engine/alf/engine.rb +4 -1
- data/lib/alf-engine/alf/engine/aggregate.rb +2 -1
- data/lib/alf-engine/alf/engine/autonum.rb +2 -1
- data/lib/alf-engine/alf/engine/clip.rb +2 -1
- data/lib/alf-engine/alf/engine/coerce.rb +2 -1
- data/lib/alf-engine/alf/engine/cog.rb +23 -0
- data/lib/alf-engine/alf/engine/compact.rb +3 -2
- data/lib/alf-engine/alf/engine/compact/set.rb +2 -1
- data/lib/alf-engine/alf/engine/compact/uniq.rb +2 -1
- data/lib/alf-engine/alf/engine/compiler.rb +60 -33
- data/lib/alf-engine/alf/engine/concat.rb +2 -1
- data/lib/alf-engine/alf/engine/defaults.rb +2 -1
- data/lib/alf-engine/alf/engine/filter.rb +4 -2
- data/lib/alf-engine/alf/engine/generator.rb +2 -1
- data/lib/alf-engine/alf/engine/group/hash.rb +4 -3
- data/lib/alf-engine/alf/engine/hierarchize.rb +87 -0
- data/lib/alf-engine/alf/engine/infer_heading.rb +2 -1
- data/lib/alf-engine/alf/engine/join.rb +5 -1
- data/lib/alf-engine/alf/engine/join/hash.rb +9 -2
- data/lib/alf-engine/alf/engine/leaf.rb +6 -1
- data/lib/alf-engine/alf/engine/materialize/array.rb +2 -1
- data/lib/alf-engine/alf/engine/materialize/hash.rb +2 -1
- data/lib/alf-engine/alf/engine/quota/cesure.rb +2 -1
- data/lib/alf-engine/alf/engine/rank/cesure.rb +2 -1
- data/lib/alf-engine/alf/engine/rename.rb +2 -1
- data/lib/alf-engine/alf/engine/semi/hash.rb +7 -1
- data/lib/alf-engine/alf/engine/set_attr.rb +4 -3
- data/lib/alf-engine/alf/engine/sort.rb +3 -2
- data/lib/alf-engine/alf/engine/sort/in_memory.rb +2 -1
- data/lib/alf-engine/alf/engine/summarize/cesure.rb +2 -1
- data/lib/alf-engine/alf/engine/summarize/hash.rb +3 -2
- data/lib/alf-engine/alf/engine/{cesure.rb → support/cesure.rb} +0 -0
- data/lib/alf-engine/alf/engine/take.rb +53 -0
- data/lib/alf-engine/alf/engine/to_array.rb +6 -5
- data/lib/alf-engine/alf/engine/type_safe.rb +2 -1
- data/lib/alf-engine/alf/engine/ungroup.rb +2 -1
- data/lib/alf-engine/alf/engine/unwrap.rb +2 -1
- data/lib/alf-engine/alf/engine/wrap.rb +2 -1
- data/lib/alf-io/alf/reader.rb +1 -1
- data/lib/alf-io/alf/reader/ruby.rb +23 -0
- data/lib/alf-io/alf/renderer/text.rb +22 -9
- data/lib/alf-lang/alf/lang/lispy.rb +41 -29
- data/lib/alf-lang/alf/lang/oo/algebra_methods.rb +17 -1
- data/lib/alf-optimizer/alf/optimizer/restrict.rb +7 -1
- data/lib/alf-predicate/alf/predicate.rb +11 -2
- data/lib/alf-relation/alf/relation.rb +21 -1
- data/lib/alf-relvar/alf/relvar.rb +21 -1
- data/lib/alf-relvar/alf/relvar/base.rb +11 -6
- data/lib/alf-relvar/alf/relvar/fake.rb +3 -2
- data/lib/alf-relvar/alf/relvar/virtual.rb +1 -2
- data/lib/alf-support/alf/support/bindable.rb +1 -1
- data/lib/alf-support/alf/support/config.rb +91 -18
- data/lib/alf-support/alf/support/tuple_scope.rb +8 -4
- data/lib/alf-types/alf/types.rb +2 -0
- data/lib/alf-types/alf/types/attr_list.rb +3 -1
- data/lib/alf-types/alf/types/heading.rb +4 -1
- data/lib/alf-types/alf/types/keys.rb +0 -4
- data/lib/alf-types/alf/types/ordering.rb +104 -18
- data/lib/alf-types/alf/types/selection.rb +18 -0
- data/lib/alf-types/alf/types/selector.rb +59 -0
- data/lib/alf-types/alf/types/tuple_computation.rb +2 -2
- data/lib/alf-types/alf/types/tuple_expression.rb +18 -2
- data/lib/alf-viewpoint/alf/viewpoint.rb +23 -8
- data/lib/alf-viewpoint/alf/viewpoint/metadata.rb +73 -0
- data/spec/integration/relation/test_extend.rb +20 -0
- data/spec/integration/relation/test_to_array.rb +1 -1
- data/spec/integration/test_examples.rb +18 -2
- data/spec/shared/a_cog.rb +36 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/unit/alf-algebra/operand/test_proxy.rb +54 -0
- data/spec/unit/alf-algebra/operator/hierarchize/test_heading.rb +23 -0
- data/spec/unit/alf-algebra/operator/project/test_key_preserving.rb +3 -0
- data/spec/unit/alf-algebra/operator/project/test_keys.rb +54 -17
- data/spec/unit/alf-algebra/operator/rank/test_keys.rb +2 -2
- data/spec/unit/alf-algebra/operator/restrict/test_keys.rb +2 -2
- data/spec/unit/alf-algebra/operator/test_page.rb +30 -0
- data/spec/unit/alf-algebra/support/test_relational.rb +3 -0
- data/spec/unit/alf-algebra/support/with_ordering/test_total_ordering.rb +61 -0
- data/spec/unit/alf-database/connection/test_reconnect.rb +1 -1
- data/spec/unit/alf-database/options/test_new.rb +4 -4
- data/spec/unit/alf-database/shared_examples/a_facade_on_database_options.rb +1 -2
- data/spec/unit/alf-engine/cog/test_to_cog.rb +14 -0
- data/spec/unit/alf-engine/compiler/test_on_frame.rb +70 -0
- data/spec/unit/alf-engine/compiler/test_on_hierarchize.rb +33 -0
- data/spec/unit/alf-engine/compiler/test_on_page.rb +128 -0
- data/spec/unit/alf-engine/compiler/test_unsupported.rb +48 -0
- data/spec/unit/alf-engine/hierarchize/test_renamer.rb +18 -0
- data/spec/unit/alf-engine/test_filter.rb +43 -11
- data/spec/unit/alf-engine/test_hierarchize.rb +71 -0
- data/spec/unit/alf-engine/test_set_attr.rb +13 -0
- data/spec/unit/alf-engine/test_take.rb +46 -0
- data/spec/unit/alf-engine/test_to_array.rb +45 -28
- data/spec/unit/alf-io/reader/{input.rb → input.rash} +0 -0
- data/spec/unit/alf-io/reader/input.ruby +4 -0
- data/spec/unit/alf-io/reader/test_rash.rb +1 -1
- data/spec/unit/alf-io/reader/test_ruby.rb +25 -0
- data/spec/unit/alf-predicate/predicate/test_evaluate.rb +51 -13
- data/spec/unit/alf-relation/relation/class/test_recursive_type.rb +42 -0
- data/spec/unit/alf-relation/relation/test_equality.rb +19 -1
- data/spec/unit/alf-relation/relation/test_relops.rb +14 -2
- data/spec/unit/alf-relation/relation/test_to_hash.rb +31 -0
- data/spec/unit/alf-relvar/base/test_connection.rb +8 -2
- data/spec/unit/alf-relvar/base/test_delete.rb +2 -2
- data/spec/unit/alf-relvar/base/test_heading.rb +2 -2
- data/spec/unit/alf-relvar/base/test_insert.rb +3 -3
- data/spec/unit/alf-relvar/base/test_keys.rb +2 -2
- data/spec/unit/alf-relvar/base/test_lock.rb +2 -2
- data/spec/unit/alf-relvar/base/test_name.rb +3 -2
- data/spec/unit/alf-relvar/base/test_oo_lang.rb +2 -1
- data/spec/unit/alf-relvar/base/test_to_cog.rb +3 -3
- data/spec/unit/alf-relvar/base/test_to_lispy.rb +3 -2
- data/spec/unit/alf-relvar/base/test_to_relvar.rb +2 -1
- data/spec/unit/alf-relvar/base/test_to_s.rb +3 -2
- data/spec/unit/alf-relvar/base/test_update.rb +5 -4
- data/spec/unit/alf-relvar/virtual/test_connection.rb +3 -2
- data/spec/unit/alf-relvar/virtual/test_delete.rb +3 -4
- data/spec/unit/alf-relvar/virtual/test_expr.rb +3 -2
- data/spec/unit/alf-relvar/virtual/test_heading.rb +5 -4
- data/spec/unit/alf-relvar/virtual/test_insert.rb +2 -2
- data/spec/unit/alf-relvar/virtual/test_keys.rb +5 -4
- data/spec/unit/alf-relvar/virtual/test_oo_lang.rb +7 -2
- data/spec/unit/alf-relvar/virtual/test_to_cog.rb +4 -3
- data/spec/unit/alf-relvar/virtual/test_to_lispy.rb +3 -6
- data/spec/unit/alf-relvar/virtual/test_to_relvar.rb +2 -1
- data/spec/unit/alf-relvar/virtual/test_to_s.rb +3 -3
- data/spec/unit/alf-relvar/virtual/test_update.rb +4 -5
- data/spec/unit/alf-support/config/test_dup.rb +58 -0
- data/spec/unit/alf-support/config/test_freeze.rb +37 -0
- data/spec/unit/alf-support/config/test_hash_get.rb +41 -0
- data/spec/unit/alf-support/config/test_hash_set.rb +61 -0
- data/spec/unit/alf-support/config/test_new.rb +10 -0
- data/spec/unit/alf-support/config/test_option.rb +15 -0
- data/spec/unit/alf-support/config/test_option_setter.rb +72 -0
- data/spec/unit/alf-support/config/test_options.rb +22 -0
- data/spec/unit/alf-support/tuple_scope/test_hash_get.rb +20 -0
- data/spec/unit/alf-support/tuple_scope/test_respond_to.rb +6 -0
- data/spec/unit/alf-support/tuple_scope/test_to_s.rb +22 -0
- data/spec/unit/alf-types/keys/test_select.rb +57 -8
- data/spec/unit/alf-types/ordering/test_coerce.rb +46 -35
- data/spec/unit/alf-types/ordering/test_dive.rb +41 -0
- data/spec/unit/alf-types/ordering/test_hash_get.rb +20 -0
- data/spec/unit/alf-types/ordering/test_merge.rb +61 -0
- data/spec/unit/alf-types/ordering/test_reverse.rb +40 -0
- data/spec/unit/alf-types/ordering/test_selectors.rb +24 -0
- data/spec/unit/alf-types/ordering/test_sorter.rb +62 -8
- data/spec/unit/alf-types/ordering/test_to_attr_list.rb +16 -4
- data/spec/unit/alf-types/ordering/test_total.rb +56 -0
- data/spec/unit/alf-types/selection/test_coerce.rb +38 -0
- data/spec/unit/alf-types/selection/test_select.rb +34 -0
- data/spec/unit/alf-types/selector/test_coerce.rb +36 -0
- data/spec/unit/alf-types/selector/test_composite_q.rb +20 -0
- data/spec/unit/alf-types/selector/test_dive.rb +32 -0
- data/spec/unit/alf-types/selector/test_select.rb +40 -0
- data/spec/unit/alf-types/selector/test_simple_q.rb +20 -0
- data/spec/unit/alf-types/selector/test_to_a.rb +20 -0
- data/spec/unit/alf-types/selector/test_to_lispy.rb +20 -0
- data/spec/unit/alf-types/selector/test_to_ruby_literal.rb +20 -0
- data/spec/unit/alf-types/tuple_expression/test_evaluate.rb +38 -0
- data/spec/unit/alf-viewpoint/metadata/test_add_members.rb +38 -0
- data/spec/unit/alf-viewpoint/metadata/test_all_members.rb +33 -0
- data/spec/unit/alf-viewpoint/metadata/test_depends.rb +50 -0
- data/spec/unit/alf-viewpoint/metadata/test_dup.rb +32 -0
- data/spec/unit/alf-viewpoint/metadata/test_expand.rb +31 -0
- data/spec/unit/alf-viewpoint/metadata/test_expects.rb +38 -0
- data/spec/unit/alf-viewpoint/metadata/test_initialize.rb +40 -0
- data/spec/unit/alf-viewpoint/metadata/test_to_module.rb +37 -0
- data/spec/unit/alf-viewpoint/test_depends.rb +18 -0
- data/spec/unit/alf-viewpoint/test_expects.rb +18 -0
- data/spec/unit/alf-viewpoint/test_members.rb +33 -0
- data/spec/unit/alf-viewpoint/test_metadata.rb +27 -0
- data/spec/unit/alf-viewpoint/test_native_const.rb +6 -0
- metadata +125 -14
- data/spec/unit/alf-database/options/test_default_viewpoint.rb +0 -25
- data/spec/unit/alf-types/keys/test_compact.rb +0 -21
- data/spec/unit/alf-types/ordering/test_plus.rb +0 -27
- data/spec/unit/alf-viewpoint/test_namespace.rb +0 -23
@@ -27,10 +27,13 @@ module Alf
|
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'when the operand is a restriction on the key' do
|
30
|
+
## [:sid]
|
30
31
|
let(:operand){
|
31
32
|
an_operand.with_heading(sid: Integer, name: String)
|
32
33
|
.with_keys([:sid])
|
33
34
|
}
|
35
|
+
# restrict: []
|
36
|
+
# project: []
|
34
37
|
let(:op){
|
35
38
|
a_lispy.project(a_lispy.restrict(operand, sid: 1), [:sid])
|
36
39
|
}
|
@@ -3,50 +3,87 @@ module Alf
|
|
3
3
|
module Algebra
|
4
4
|
describe Project, 'keys' do
|
5
5
|
|
6
|
-
let(:operand){
|
7
|
-
an_operand.with_heading(id: Integer, name: String, status: String).
|
8
|
-
with_keys([:id], [:name])
|
9
|
-
}
|
10
|
-
|
11
6
|
subject{ op.keys }
|
12
7
|
|
13
|
-
context '
|
14
|
-
let(:
|
15
|
-
|
16
|
-
|
17
|
-
let(:expected){
|
18
|
-
Keys[ [:id] ]
|
8
|
+
context 'with two single keys' do
|
9
|
+
let(:operand){
|
10
|
+
an_operand.with_heading(id: Integer, name: String, status: String, city: String).
|
11
|
+
with_keys([:id], [:name])
|
19
12
|
}
|
20
13
|
|
21
|
-
|
14
|
+
context 'when conserving at least one key' do
|
15
|
+
let(:op){
|
16
|
+
a_lispy.project(operand, [:id, :status])
|
17
|
+
}
|
18
|
+
let(:expected){
|
19
|
+
Keys[ [:id] ]
|
20
|
+
}
|
21
|
+
|
22
|
+
it { should eq(expected) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when projecting all keys away' do
|
26
|
+
let(:op){
|
27
|
+
a_lispy.project(operand, [:status])
|
28
|
+
}
|
29
|
+
let(:expected){
|
30
|
+
Keys[ [:status] ]
|
31
|
+
}
|
32
|
+
|
33
|
+
it { should eq(expected) }
|
34
|
+
end
|
22
35
|
end
|
23
36
|
|
24
|
-
context 'when
|
37
|
+
context 'when a key is cut' do
|
38
|
+
# 1, 1, 1
|
39
|
+
# 1, 2, 3
|
40
|
+
let(:operand){
|
41
|
+
an_operand.with_heading(sid: Integer, pid: Integer, qty: Integer)
|
42
|
+
.with_keys([:sid, :pid])
|
43
|
+
}
|
44
|
+
# 1, _, 1
|
45
|
+
# 1, _, 3
|
25
46
|
let(:op){
|
26
|
-
a_lispy.project(operand, [:
|
47
|
+
a_lispy.project(operand, [:sid, :qty])
|
27
48
|
}
|
28
49
|
let(:expected){
|
29
|
-
Keys[ [:
|
50
|
+
Keys[ [:sid, :qty] ]
|
30
51
|
}
|
31
52
|
|
32
53
|
it { should eq(expected) }
|
33
54
|
end
|
34
55
|
|
35
56
|
context 'when a key is projected due to a constant restriction' do
|
57
|
+
# 1, 1, 1
|
58
|
+
# 1, 2, 3
|
36
59
|
let(:operand){
|
37
60
|
an_operand.with_heading(sid: Integer, pid: Integer)
|
38
61
|
.with_keys([:sid, :pid])
|
39
62
|
}
|
63
|
+
# 1, _, 1
|
40
64
|
let(:op){
|
41
|
-
a_lispy.project(a_lispy.restrict(operand,
|
65
|
+
a_lispy.project(a_lispy.restrict(operand, pid: 1), [:sid, :qty])
|
42
66
|
}
|
43
67
|
let(:expected){
|
44
|
-
Keys[ [:
|
68
|
+
Keys[ [:sid] ]
|
45
69
|
}
|
46
70
|
|
47
71
|
it { should eq(expected) }
|
48
72
|
end
|
49
73
|
|
74
|
+
context 'when a projection leads to an empty key' do
|
75
|
+
## 1, Jones
|
76
|
+
let(:operand){
|
77
|
+
an_operand.with_heading(sid: Integer, name: String)
|
78
|
+
.with_keys([:sid])
|
79
|
+
}
|
80
|
+
let(:op){
|
81
|
+
a_lispy.project(a_lispy.restrict(operand, sid: 1), [:sid])
|
82
|
+
}
|
83
|
+
|
84
|
+
it { should eq(Keys[[]]) }
|
85
|
+
end
|
86
|
+
|
50
87
|
end
|
51
88
|
end
|
52
89
|
end
|
@@ -4,7 +4,7 @@ module Alf
|
|
4
4
|
describe Rank, 'keys' do
|
5
5
|
|
6
6
|
let(:operand){
|
7
|
-
an_operand.with_heading(:
|
7
|
+
an_operand.with_heading(id: Integer, name: String, hobby: Tuple[name: String]).with_keys([:id])
|
8
8
|
}
|
9
9
|
|
10
10
|
subject{ op.keys }
|
@@ -22,7 +22,7 @@ module Alf
|
|
22
22
|
|
23
23
|
context 'when the order relation does contain a key' do
|
24
24
|
let(:op){
|
25
|
-
a_lispy.rank(operand, [[:name, :asc], [:id, :desc]], :rank)
|
25
|
+
a_lispy.rank(operand, [[[:hobby, :name], :asc], [:id, :desc]], :rank)
|
26
26
|
}
|
27
27
|
let(:expected){
|
28
28
|
Keys[ [:id], [:rank] ]
|
@@ -24,7 +24,7 @@ module Alf
|
|
24
24
|
an_operand.with_heading(id: Fixnum, name: String).with_keys([:id, :name])
|
25
25
|
}
|
26
26
|
let(:op){
|
27
|
-
a_lispy.restrict(operand,
|
27
|
+
a_lispy.restrict(operand, id: 12)
|
28
28
|
}
|
29
29
|
let(:expected){
|
30
30
|
Keys[ [:name] ]
|
@@ -38,7 +38,7 @@ module Alf
|
|
38
38
|
an_operand.with_heading(id: Fixnum, name: String).with_keys([:id, :name])
|
39
39
|
}
|
40
40
|
let(:op){
|
41
|
-
a_lispy.restrict(operand,
|
41
|
+
a_lispy.restrict(operand, id: 12, name: "Smith")
|
42
42
|
}
|
43
43
|
let(:expected){
|
44
44
|
Keys[ [] ]
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
module Algebra
|
4
|
+
describe Page do
|
5
|
+
|
6
|
+
let(:operator_class){ Page }
|
7
|
+
|
8
|
+
it_should_behave_like("An operator class")
|
9
|
+
|
10
|
+
subject{
|
11
|
+
a_lispy.page(an_operand, [[:name, :asc]], 2)
|
12
|
+
}
|
13
|
+
|
14
|
+
it { should be_a(Page) }
|
15
|
+
|
16
|
+
it 'should have correct ordering' do
|
17
|
+
subject.ordering.should eq(Ordering.coerce([[:name, :asc]]))
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have correct page index' do
|
21
|
+
subject.page_index.should eq(2)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have default page size' do
|
25
|
+
subject.page_size.should eq(25)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -8,13 +8,16 @@ module Alf
|
|
8
8
|
Relational.each{|m| x << m}
|
9
9
|
x.sort{|m1,m2| m1.name.to_s <=> m2.name.to_s}.should == [
|
10
10
|
Extend,
|
11
|
+
Frame,
|
11
12
|
Group,
|
13
|
+
Hierarchize,
|
12
14
|
InferHeading,
|
13
15
|
Intersect,
|
14
16
|
Join,
|
15
17
|
Matching,
|
16
18
|
Minus,
|
17
19
|
NotMatching,
|
20
|
+
Page,
|
18
21
|
Project,
|
19
22
|
Quota,
|
20
23
|
Rank,
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
module Algebra
|
4
|
+
describe WithOrdering, 'total_ordering' do
|
5
|
+
include WithOrdering
|
6
|
+
|
7
|
+
subject{ total_ordering }
|
8
|
+
|
9
|
+
def keys
|
10
|
+
operand.keys
|
11
|
+
end
|
12
|
+
|
13
|
+
def heading
|
14
|
+
operand.heading
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when the initial ordering covers a key' do
|
18
|
+
let(:operand){
|
19
|
+
an_operand.with_heading(id: Fixnum, name: String).with_keys([:id])
|
20
|
+
}
|
21
|
+
let(:ordering){
|
22
|
+
Ordering.new([[:id, :desc]])
|
23
|
+
}
|
24
|
+
let(:expected){
|
25
|
+
Ordering.new([[:id, :desc]])
|
26
|
+
}
|
27
|
+
|
28
|
+
it { should eq(expected) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when the initial ordering does not cover a key' do
|
32
|
+
let(:operand){
|
33
|
+
an_operand.with_heading(id: Fixnum, name: String).with_keys([:id, :name])
|
34
|
+
}
|
35
|
+
let(:ordering){
|
36
|
+
Ordering.new([[:name, :desc]])
|
37
|
+
}
|
38
|
+
let(:expected){
|
39
|
+
Ordering.new([[:name, :desc], [:id, :asc]])
|
40
|
+
}
|
41
|
+
|
42
|
+
it { should eq(expected) }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when no key' do
|
46
|
+
let(:operand){
|
47
|
+
an_operand.with_heading(id: Fixnum, name: String)
|
48
|
+
}
|
49
|
+
let(:ordering){
|
50
|
+
Ordering.new([[:name, :desc]])
|
51
|
+
}
|
52
|
+
let(:expected){
|
53
|
+
Ordering.new([[:name, :desc], [:id, :asc]])
|
54
|
+
}
|
55
|
+
|
56
|
+
it { should eq(expected) }
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -7,12 +7,12 @@ module Alf
|
|
7
7
|
|
8
8
|
subject{ Options.new(h) }
|
9
9
|
|
10
|
-
context 'when valid, coercable options with
|
11
|
-
let(:h){ {schema_cache: "false",
|
10
|
+
context 'when valid, coercable options with viewpoint' do
|
11
|
+
let(:h){ {schema_cache: "false", viewpoint: viewpoint} }
|
12
12
|
|
13
13
|
it 'sets the options as expected' do
|
14
14
|
subject.schema_cache?.should eq(false)
|
15
|
-
subject.
|
15
|
+
subject.viewpoint.should be(viewpoint)
|
16
16
|
subject.viewpoint.should be(viewpoint)
|
17
17
|
end
|
18
18
|
end
|
@@ -22,7 +22,7 @@ module Alf
|
|
22
22
|
|
23
23
|
it 'sets the options as expected' do
|
24
24
|
subject.schema_cache?.should eq(false)
|
25
|
-
subject.
|
25
|
+
subject.viewpoint.should be(viewpoint)
|
26
26
|
subject.viewpoint.should be(viewpoint)
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
module Engine
|
4
|
+
describe Compiler, 'test_on_frame' do
|
5
|
+
|
6
|
+
subject{ Compiler.new.call(expr) }
|
7
|
+
|
8
|
+
shared_examples_for "a traceable take" do
|
9
|
+
it_should_behave_like "a traceable cog"
|
10
|
+
|
11
|
+
it {
|
12
|
+
should be_a(Engine::Take)
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when keys are known and a positive index' do
|
17
|
+
let(:operand){
|
18
|
+
an_operand.with_heading(id: Fixnum, name: String).with_keys([:id])
|
19
|
+
}
|
20
|
+
let(:expr){
|
21
|
+
a_lispy.frame(operand, [], 3, 8)
|
22
|
+
}
|
23
|
+
|
24
|
+
it_should_behave_like "a traceable take"
|
25
|
+
|
26
|
+
it 'should have correct offset' do
|
27
|
+
subject.offset.should eq(3)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should have correct limit' do
|
31
|
+
subject.limit.should eq(8)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have a sort as child' do
|
35
|
+
subject.operand.should be_a(Engine::Sort)
|
36
|
+
subject.operand.ordering.should eq(Ordering.new([[:id, :asc]]))
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have a leaf as child.child' do
|
40
|
+
subject.operand.operand.should be_a(Leaf)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when keys and heading are not supported' do
|
45
|
+
let(:operand){
|
46
|
+
an_operand
|
47
|
+
}
|
48
|
+
let(:expr){
|
49
|
+
a_lispy.frame(operand, [[:id, :asc]], 3, 8)
|
50
|
+
}
|
51
|
+
|
52
|
+
it_should_behave_like "a traceable take"
|
53
|
+
|
54
|
+
it 'should have correct offset' do
|
55
|
+
subject.offset.should eq(3)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should have correct limit' do
|
59
|
+
subject.limit.should eq(8)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should have a sort as child and stick to initial ordering' do
|
63
|
+
subject.operand.should be_a(Engine::Sort)
|
64
|
+
subject.operand.ordering.should eq(Ordering.new([[:id, :asc]]))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
module Engine
|
4
|
+
describe Compiler, 'test_on_hierarchize' do
|
5
|
+
|
6
|
+
subject{ Compiler.new.call(expr) }
|
7
|
+
|
8
|
+
context 'the normal case' do
|
9
|
+
let(:operand){
|
10
|
+
an_operand.with_heading(id: Fixnum, parent: Integer).with_keys([:id])
|
11
|
+
}
|
12
|
+
let(:expr){
|
13
|
+
a_lispy.hierarchize(operand, :id, :parent, :as)
|
14
|
+
}
|
15
|
+
|
16
|
+
it{ should be_a(Engine::Hierarchize) }
|
17
|
+
|
18
|
+
it 'should have correct id list' do
|
19
|
+
subject.id.should eq(AttrList[:id])
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have correct parent list' do
|
23
|
+
subject.parent.should eq(AttrList[:parent])
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should have correct children name' do
|
27
|
+
subject.children.should eq(:as)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
module Engine
|
4
|
+
describe Compiler, 'test_on_page' do
|
5
|
+
|
6
|
+
subject{ Compiler.new.call(expr) }
|
7
|
+
|
8
|
+
shared_examples_for "a traceable take" do
|
9
|
+
it_should_behave_like "a traceable cog"
|
10
|
+
|
11
|
+
it {
|
12
|
+
should be_a(Engine::Take)
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when keys are known and a positive index' do
|
17
|
+
let(:operand){
|
18
|
+
an_operand.with_heading(id: Fixnum, name: String).with_keys([:id])
|
19
|
+
}
|
20
|
+
let(:expr){
|
21
|
+
a_lispy.page(operand, [], 3, page_size: 8)
|
22
|
+
}
|
23
|
+
|
24
|
+
it_should_behave_like "a traceable take"
|
25
|
+
|
26
|
+
it 'should have correct offset' do
|
27
|
+
subject.offset.should eq(16)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should have correct limit' do
|
31
|
+
subject.limit.should eq(8)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have a sort as child' do
|
35
|
+
subject.operand.should be_a(Engine::Sort)
|
36
|
+
subject.operand.ordering.should eq(Ordering.new([[:id, :asc]]))
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have a leaf as child.child' do
|
40
|
+
subject.operand.operand.should be_a(Leaf)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when keys are known and a page 1' do
|
45
|
+
let(:operand){
|
46
|
+
an_operand.with_heading(id: Fixnum, name: String).with_keys([:id])
|
47
|
+
}
|
48
|
+
let(:expr){
|
49
|
+
a_lispy.page(operand, [], 1)
|
50
|
+
}
|
51
|
+
|
52
|
+
it_should_behave_like "a traceable take"
|
53
|
+
|
54
|
+
it 'should have offset 0' do
|
55
|
+
subject.offset.should eq(0)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'when keys are known and a negative index' do
|
60
|
+
let(:operand){
|
61
|
+
an_operand.with_heading(id: Fixnum, name: String).with_keys([:id])
|
62
|
+
}
|
63
|
+
let(:expr){
|
64
|
+
a_lispy.page(operand, [], -3, page_size: 8)
|
65
|
+
}
|
66
|
+
|
67
|
+
it_should_behave_like "a traceable take"
|
68
|
+
|
69
|
+
it 'should have correct offset' do
|
70
|
+
subject.offset.should eq(16)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should have correct limit' do
|
74
|
+
subject.limit.should eq(8)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should have a sort with inverse ordering as child' do
|
78
|
+
subject.operand.should be_a(Engine::Sort)
|
79
|
+
subject.operand.ordering.should eq(Ordering.new([[:id, :desc]]))
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should have a leaf as child.child' do
|
83
|
+
subject.operand.operand.should be_a(Leaf)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when keys are known and a page -1' do
|
88
|
+
let(:operand){
|
89
|
+
an_operand.with_heading(id: Fixnum, name: String).with_keys([:id])
|
90
|
+
}
|
91
|
+
let(:expr){
|
92
|
+
a_lispy.page(operand, [], -1)
|
93
|
+
}
|
94
|
+
|
95
|
+
it_should_behave_like "a traceable take"
|
96
|
+
|
97
|
+
it 'should have offset 0' do
|
98
|
+
subject.offset.should eq(0)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when keys and heading are not supported' do
|
103
|
+
let(:operand){
|
104
|
+
an_operand
|
105
|
+
}
|
106
|
+
let(:expr){
|
107
|
+
a_lispy.page(operand, [[:id, :asc]], 3, page_size: 8)
|
108
|
+
}
|
109
|
+
|
110
|
+
it_should_behave_like "a traceable take"
|
111
|
+
|
112
|
+
it 'should have correct offset' do
|
113
|
+
subject.offset.should eq(16)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should have correct limit' do
|
117
|
+
subject.limit.should eq(8)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should have a sort as child and stick to initial ordering' do
|
121
|
+
subject.operand.should be_a(Engine::Sort)
|
122
|
+
subject.operand.ordering.should eq(Ordering.new([[:id, :asc]]))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|