alf-sequel 0.13.0
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/CHANGELOG.md +4 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +38 -0
- data/LICENCE.md +22 -0
- data/Manifest.txt +12 -0
- data/README.md +11 -0
- data/Rakefile +11 -0
- data/lib/alf/sequel/adapter.rb +57 -0
- data/lib/alf/sequel/cog.rb +92 -0
- data/lib/alf/sequel/compiler/predicate.rb +76 -0
- data/lib/alf/sequel/compiler.rb +168 -0
- data/lib/alf/sequel/connection/connection_methods.rb +46 -0
- data/lib/alf/sequel/connection/schema_methods.rb +76 -0
- data/lib/alf/sequel/connection/update_methods.rb +63 -0
- data/lib/alf/sequel/connection.rb +23 -0
- data/lib/alf/sequel/loader.rb +2 -0
- data/lib/alf/sequel/unit_of_work/atomic.rb +35 -0
- data/lib/alf/sequel/unit_of_work/delete.rb +24 -0
- data/lib/alf/sequel/unit_of_work/insert.rb +60 -0
- data/lib/alf/sequel/unit_of_work/update.rb +60 -0
- data/lib/alf/sequel/unit_of_work.rb +11 -0
- data/lib/alf/sequel/version.rb +16 -0
- data/lib/alf/sequel.rb +7 -0
- data/lib/alf-sequel.rb +1 -0
- data/spec/adapter/test_recognize.rb +50 -0
- data/spec/alf.db +0 -0
- data/spec/compiler/test_clip.rb +40 -0
- data/spec/compiler/test_compact.rb +18 -0
- data/spec/compiler/test_extend.rb +16 -0
- data/spec/compiler/test_intersect.rb +18 -0
- data/spec/compiler/test_join.rb +18 -0
- data/spec/compiler/test_leaf_operand.rb +24 -0
- data/spec/compiler/test_matching.rb +34 -0
- data/spec/compiler/test_not_matching.rb +34 -0
- data/spec/compiler/test_predicate.rb +141 -0
- data/spec/compiler/test_project.rb +64 -0
- data/spec/compiler/test_rename.rb +26 -0
- data/spec/compiler/test_restrict.rb +48 -0
- data/spec/compiler/test_sort.rb +18 -0
- data/spec/compiler/test_union.rb +18 -0
- data/spec/compiler_helper.rb +34 -0
- data/spec/connection/test_connection_uri.rb +54 -0
- data/spec/connection/test_delete.rb +20 -0
- data/spec/connection/test_heading.rb +16 -0
- data/spec/connection/test_insert.rb +24 -0
- data/spec/connection/test_keys.rb +24 -0
- data/spec/connection/test_lock.rb +15 -0
- data/spec/connection/test_ping.rb +26 -0
- data/spec/connection/test_relvar.rb +16 -0
- data/spec/connection/test_update.rb +20 -0
- data/spec/fixtures/sap.db +0 -0
- data/spec/fixtures/sap.rb +43 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/test_assumptions.rb +14 -0
- data/spec/test_sequel.rb +10 -0
- data/spec/unit_of_work/atomic/test_run.rb +72 -0
- data/spec/unit_of_work/delete/test_delete.rb +39 -0
- data/spec/unit_of_work/insert/test_run.rb +71 -0
- data/spec/unit_of_work/update/test_run.rb +39 -0
- data/tasks/fixtures.rake +12 -0
- data/tasks/gem.rake +8 -0
- data/tasks/test.rake +6 -0
- metadata +174 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
module Alf
|
3
|
+
module Sequel
|
4
|
+
module UnitOfWork
|
5
|
+
describe Insert, "run" do
|
6
|
+
|
7
|
+
let(:conn){ sap_memory.adapter_connection }
|
8
|
+
let(:uow){
|
9
|
+
UnitOfWork::Insert.new(conn, relvar_name, tuples)
|
10
|
+
}
|
11
|
+
subject{ uow.run }
|
12
|
+
|
13
|
+
before do
|
14
|
+
subject.should be(uow)
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when the primary key is not composite' do
|
18
|
+
let(:relvar_name){ :suppliers }
|
19
|
+
|
20
|
+
context 'with only one tuple' do
|
21
|
+
let(:tuples){ [{sid: 10, name: "Marcus", city: "Ouagadougou", status: 55}] }
|
22
|
+
|
23
|
+
it "inserts the tuple" do
|
24
|
+
conn.dataset(:suppliers).where(sid: 10).should_not be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'keeps information about inserted tuples' do
|
28
|
+
uow.matching_relation.should eq(Relation sid: 10)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with multiple tuples' do
|
33
|
+
let(:tuples){ [
|
34
|
+
{sid: 10, name: "Marcus", city: "Ouagadougou", status: 55},
|
35
|
+
{sid: 11, name: "Demete", city: "Albertville", status: 56}
|
36
|
+
]}
|
37
|
+
|
38
|
+
it "inserts the tuples" do
|
39
|
+
conn.dataset(:suppliers).where(sid: 10).should_not be_empty
|
40
|
+
conn.dataset(:suppliers).where(sid: 11).should_not be_empty
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'keeps information about inserted tuples' do
|
44
|
+
uow.matching_relation.should eq(Relation sid: [10, 11])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when the primary key is composite' do
|
50
|
+
let(:relvar_name){ :supplies }
|
51
|
+
|
52
|
+
let(:tuples){ [
|
53
|
+
{sid: 5, pid: 1},
|
54
|
+
{sid: 5, pid: 2}
|
55
|
+
]}
|
56
|
+
|
57
|
+
it "inserts the tuples" do
|
58
|
+
conn.dataset(:supplies).where(sid: 5).to_a.size.should eq(2)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'keeps information about inserted tuples' do
|
62
|
+
pending{
|
63
|
+
uow.matching_relation.should eq(Relation(tuples))
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end # module UnitOfWork
|
70
|
+
end # module Sequel
|
71
|
+
end # module Alf
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
module Alf
|
3
|
+
module Sequel
|
4
|
+
module UnitOfWork
|
5
|
+
describe Update, "run" do
|
6
|
+
|
7
|
+
let(:conn){ sap_memory.adapter_connection }
|
8
|
+
let(:uow){
|
9
|
+
UnitOfWork::Update.new(conn, relvar_name, updating, predicate)
|
10
|
+
}
|
11
|
+
let(:updating){ {status: 55} }
|
12
|
+
subject{ uow.run }
|
13
|
+
|
14
|
+
before do
|
15
|
+
subject.should be(uow)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when predicate is a tautology' do
|
19
|
+
let(:relvar_name){ :suppliers }
|
20
|
+
let(:predicate){ Predicate.tautology }
|
21
|
+
|
22
|
+
it 'updates all tuples' do
|
23
|
+
conn.dataset(relvar_name).where(status: 55).to_a.size.should eq(5)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when predicate is not a tautology' do
|
28
|
+
let(:relvar_name){ :suppliers }
|
29
|
+
let(:predicate){ Predicate.eq(sid: 1) }
|
30
|
+
|
31
|
+
it 'removes only targetted tuples' do
|
32
|
+
conn.dataset(relvar_name).where(status: 55).to_a.size.should eq(1)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end # module UnitOfWork
|
38
|
+
end # module Sequel
|
39
|
+
end # module Alf
|
data/tasks/fixtures.rake
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
task :fixtures do
|
2
|
+
require 'path'
|
3
|
+
require "sequel"
|
4
|
+
require 'alf-sequel'
|
5
|
+
require_relative '../spec/fixtures/sap'
|
6
|
+
|
7
|
+
path = Path.relative("../spec/fixtures/sap.db")
|
8
|
+
path.unlink if path.exist?
|
9
|
+
path.parent.mkdir_p unless path.parent.exist?
|
10
|
+
|
11
|
+
SAP.create! Alf::Sequel::Adapter.sequel_db(path)
|
12
|
+
end
|
data/tasks/gem.rake
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'rubygems/package_task'
|
2
|
+
gemspec_file = File.expand_path('../../alf-sequel.gemspec', __FILE__)
|
3
|
+
gemspec = Kernel.eval(File.read(gemspec_file))
|
4
|
+
Gem::PackageTask.new(gemspec) do |t|
|
5
|
+
t.name = gemspec.name
|
6
|
+
t.version = gemspec.version
|
7
|
+
t.package_files = gemspec.files
|
8
|
+
end
|
data/tasks/test.rake
ADDED
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alf-sequel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.13.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bernard Lambeau
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '10.1'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '10.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.14'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.14'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: alf-core
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.13.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.13.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: sequel
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.48'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.48'
|
78
|
+
description: This project implements an Alf adapter on top of the awesome sequel toolkit.
|
79
|
+
email:
|
80
|
+
- blambeau at gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- CHANGELOG.md
|
86
|
+
- Gemfile
|
87
|
+
- Gemfile.lock
|
88
|
+
- lib/alf/sequel/adapter.rb
|
89
|
+
- lib/alf/sequel/cog.rb
|
90
|
+
- lib/alf/sequel/compiler/predicate.rb
|
91
|
+
- lib/alf/sequel/compiler.rb
|
92
|
+
- lib/alf/sequel/connection/connection_methods.rb
|
93
|
+
- lib/alf/sequel/connection/schema_methods.rb
|
94
|
+
- lib/alf/sequel/connection/update_methods.rb
|
95
|
+
- lib/alf/sequel/connection.rb
|
96
|
+
- lib/alf/sequel/loader.rb
|
97
|
+
- lib/alf/sequel/unit_of_work/atomic.rb
|
98
|
+
- lib/alf/sequel/unit_of_work/delete.rb
|
99
|
+
- lib/alf/sequel/unit_of_work/insert.rb
|
100
|
+
- lib/alf/sequel/unit_of_work/update.rb
|
101
|
+
- lib/alf/sequel/unit_of_work.rb
|
102
|
+
- lib/alf/sequel/version.rb
|
103
|
+
- lib/alf/sequel.rb
|
104
|
+
- lib/alf-sequel.rb
|
105
|
+
- LICENCE.md
|
106
|
+
- Manifest.txt
|
107
|
+
- Rakefile
|
108
|
+
- README.md
|
109
|
+
- spec/adapter/test_recognize.rb
|
110
|
+
- spec/alf.db
|
111
|
+
- spec/compiler/test_clip.rb
|
112
|
+
- spec/compiler/test_compact.rb
|
113
|
+
- spec/compiler/test_extend.rb
|
114
|
+
- spec/compiler/test_intersect.rb
|
115
|
+
- spec/compiler/test_join.rb
|
116
|
+
- spec/compiler/test_leaf_operand.rb
|
117
|
+
- spec/compiler/test_matching.rb
|
118
|
+
- spec/compiler/test_not_matching.rb
|
119
|
+
- spec/compiler/test_predicate.rb
|
120
|
+
- spec/compiler/test_project.rb
|
121
|
+
- spec/compiler/test_rename.rb
|
122
|
+
- spec/compiler/test_restrict.rb
|
123
|
+
- spec/compiler/test_sort.rb
|
124
|
+
- spec/compiler/test_union.rb
|
125
|
+
- spec/compiler_helper.rb
|
126
|
+
- spec/connection/test_connection_uri.rb
|
127
|
+
- spec/connection/test_delete.rb
|
128
|
+
- spec/connection/test_heading.rb
|
129
|
+
- spec/connection/test_insert.rb
|
130
|
+
- spec/connection/test_keys.rb
|
131
|
+
- spec/connection/test_lock.rb
|
132
|
+
- spec/connection/test_ping.rb
|
133
|
+
- spec/connection/test_relvar.rb
|
134
|
+
- spec/connection/test_update.rb
|
135
|
+
- spec/fixtures/sap.db
|
136
|
+
- spec/fixtures/sap.rb
|
137
|
+
- spec/spec_helper.rb
|
138
|
+
- spec/test_assumptions.rb
|
139
|
+
- spec/test_sequel.rb
|
140
|
+
- spec/unit_of_work/atomic/test_run.rb
|
141
|
+
- spec/unit_of_work/delete/test_delete.rb
|
142
|
+
- spec/unit_of_work/insert/test_run.rb
|
143
|
+
- spec/unit_of_work/update/test_run.rb
|
144
|
+
- tasks/fixtures.rake
|
145
|
+
- tasks/gem.rake
|
146
|
+
- tasks/test.rake
|
147
|
+
homepage: http://github.com/blambeau/alf-sequel
|
148
|
+
licenses: []
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
segments:
|
160
|
+
- 0
|
161
|
+
hash: 2828513476823415639
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
none: false
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubyforge_project:
|
170
|
+
rubygems_version: 1.8.25
|
171
|
+
signing_key:
|
172
|
+
specification_version: 3
|
173
|
+
summary: A sequel adapter for alf
|
174
|
+
test_files: []
|