data_objects 0.10.8 → 0.10.9
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.markdown +4 -0
- data/lib/data_objects/command.rb +1 -0
- data/lib/data_objects/spec/shared/command_spec.rb +21 -19
- data/lib/data_objects/spec/shared/connection_spec.rb +23 -24
- data/lib/data_objects/spec/shared/typecast/string_spec.rb +2 -2
- data/lib/data_objects/version.rb +1 -1
- data/spec/pooling_spec.rb +1 -1
- metadata +7 -16
data/ChangeLog.markdown
CHANGED
data/lib/data_objects/command.rb
CHANGED
@@ -7,9 +7,11 @@ shared_examples_for 'a Command' do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
before do
|
10
|
-
@connection
|
11
|
-
@command
|
12
|
-
@reader
|
10
|
+
@connection = DataObjects::Connection.new(CONFIG.uri)
|
11
|
+
@command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
|
12
|
+
@reader = @connection.create_command("SELECT code, name FROM widgets WHERE ad_description = ?")
|
13
|
+
@arg_command = @connection.create_command("INSERT INTO users (name, fired_at) VALUES (?, ?)")
|
14
|
+
@arg_reader = @connection.create_command("SELECT code, name FROM widgets WHERE ad_description = ? AND whitepaper_text = ?")
|
13
15
|
end
|
14
16
|
|
15
17
|
after do
|
@@ -32,14 +34,14 @@ shared_examples_for 'a Command' do
|
|
32
34
|
expect { @invalid_command.execute_non_query }.to raise_error(DataObjects::SQLError)
|
33
35
|
end
|
34
36
|
|
35
|
-
it 'should raise an error with too
|
36
|
-
expect { @
|
37
|
-
/Binding mismatch:
|
37
|
+
it 'should raise an error with too many binding parameters' do
|
38
|
+
expect { @arg_command.execute_non_query("Too", Date.today, "Many") }.to raise_error(ArgumentError,
|
39
|
+
/Binding mismatch: 3 for 2/)
|
38
40
|
end
|
39
41
|
|
40
|
-
it 'should raise an error with too
|
41
|
-
expect { @
|
42
|
-
/Binding mismatch:
|
42
|
+
it 'should raise an error with too few binding parameters' do
|
43
|
+
expect { @arg_command.execute_non_query("Few") }.to raise_error(ArgumentError,
|
44
|
+
/Binding mismatch: 1 for 2/)
|
43
45
|
end
|
44
46
|
|
45
47
|
end
|
@@ -47,7 +49,7 @@ shared_examples_for 'a Command' do
|
|
47
49
|
describe 'with a valid statement' do
|
48
50
|
|
49
51
|
it 'should not raise an error with an explicit nil as parameter' do
|
50
|
-
expect { @
|
52
|
+
expect { @arg_command.execute_non_query(nil, nil) }.not_to raise_error(ArgumentError)
|
51
53
|
end
|
52
54
|
|
53
55
|
end
|
@@ -73,7 +75,7 @@ shared_examples_for 'a Command' do
|
|
73
75
|
describe 'with an invalid reader' do
|
74
76
|
|
75
77
|
before do
|
76
|
-
@invalid_reader = @connection.create_command("SELECT * FROM non_existent_widgets WHERE ad_description = ?")
|
78
|
+
@invalid_reader = @connection.create_command("SELECT * FROM non_existent_widgets WHERE ad_description = ? AND white_paper_text = ?")
|
77
79
|
end
|
78
80
|
|
79
81
|
it 'should raise an error on an invalid query' do
|
@@ -81,14 +83,14 @@ shared_examples_for 'a Command' do
|
|
81
83
|
expect { @invalid_reader.execute_reader }.to raise_error # (ArgumentError, DataObjects::SQLError)
|
82
84
|
end
|
83
85
|
|
84
|
-
it 'should raise an error with too few binding parameters' do
|
85
|
-
expect { @
|
86
|
-
/Binding mismatch:
|
86
|
+
it 'should raise an error with too many few binding parameters' do
|
87
|
+
expect { @arg_reader.execute_reader("Too", "Many", "Args") }.to raise_error(ArgumentError,
|
88
|
+
/Binding mismatch: 3 for 2/)
|
87
89
|
end
|
88
90
|
|
89
|
-
it 'should raise an error with too
|
90
|
-
expect { @
|
91
|
-
/Binding mismatch:
|
91
|
+
it 'should raise an error with too few binding parameters' do
|
92
|
+
expect { @arg_reader.execute_reader("Few") }.to raise_error(ArgumentError,
|
93
|
+
/Binding mismatch: 1 for 2/)
|
92
94
|
end
|
93
95
|
|
94
96
|
end
|
@@ -96,7 +98,7 @@ shared_examples_for 'a Command' do
|
|
96
98
|
describe 'with a valid reader' do
|
97
99
|
|
98
100
|
it 'should not raise an error with an explicit nil as parameter' do
|
99
|
-
expect { @
|
101
|
+
expect { @arg_reader.execute_reader(nil, nil) }.not_to raise_error(ArgumentError)
|
100
102
|
end
|
101
103
|
|
102
104
|
end
|
@@ -127,7 +129,7 @@ shared_examples_for 'a Command' do
|
|
127
129
|
end
|
128
130
|
|
129
131
|
it 'should raise an error when types are set' do
|
130
|
-
expect { @
|
132
|
+
expect { @arg_command.execute_non_query("Few") }.to raise_error(ArgumentError)
|
131
133
|
end
|
132
134
|
|
133
135
|
end
|
@@ -1,3 +1,13 @@
|
|
1
|
+
def test_connection(conn)
|
2
|
+
reader = conn.create_command(CONFIG.testsql || "SELECT 1").execute_reader
|
3
|
+
reader.next!
|
4
|
+
result = reader.values[0]
|
5
|
+
result
|
6
|
+
ensure
|
7
|
+
reader.close
|
8
|
+
conn.close
|
9
|
+
end
|
10
|
+
|
1
11
|
shared_examples_for 'a Connection' do
|
2
12
|
|
3
13
|
before :all do
|
@@ -25,21 +35,15 @@ shared_examples_for 'a Connection' do
|
|
25
35
|
end
|
26
36
|
|
27
37
|
describe 'various connection URIs' do
|
28
|
-
def test_connection(conn)
|
29
|
-
reader = conn.create_command(CONFIG.testsql || "SELECT 1").execute_reader
|
30
|
-
reader.next!
|
31
|
-
reader.values[0]
|
32
|
-
end
|
33
38
|
|
34
39
|
it 'should open with an uri object' do
|
35
40
|
uri = DataObjects::URI.new(
|
36
|
-
@driver,
|
37
|
-
@user,
|
38
|
-
@password,
|
39
|
-
@host,
|
40
|
-
@port && @port.to_i,
|
41
|
-
@database
|
42
|
-
nil, nil
|
41
|
+
:scheme => @driver,
|
42
|
+
:user => @user,
|
43
|
+
:password => @password,
|
44
|
+
:host => @host,
|
45
|
+
:port => @port && @port.to_i,
|
46
|
+
:path => @database
|
43
47
|
)
|
44
48
|
conn = DataObjects::Connection.new(uri)
|
45
49
|
test_connection(conn).should == 1
|
@@ -109,10 +113,6 @@ shared_examples_for 'a Connection with authentication support' do
|
|
109
113
|
lambda { DataObjects::Connection.new(uri) }
|
110
114
|
end
|
111
115
|
|
112
|
-
it 'should raise an error if no database specified' do
|
113
|
-
connecting_with("#{@driver}://#{@user}:#{@password}@#{@host}:#{@port}").should raise_error #(ArgumentError, DataObjects::Error)
|
114
|
-
end
|
115
|
-
|
116
116
|
it 'should raise an error if bad username is given' do
|
117
117
|
connecting_with("#{@driver}://thisreallyshouldntexist:#{@password}@#{@host}:#{@port}#{@database}").should raise_error #(ArgumentError, DataObjects::Error)
|
118
118
|
end
|
@@ -137,14 +137,13 @@ shared_examples_for 'a Connection with authentication support' do
|
|
137
137
|
|
138
138
|
end
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
conn.close
|
140
|
+
shared_examples_for 'a Connection allowing default database' do
|
141
|
+
describe 'with a URI without a database' do
|
142
|
+
it 'should connect properly' do
|
143
|
+
conn = DataObjects::Connection.new("#{@driver}://#{@user}:#{@password}@#{@host}:#{@port}")
|
144
|
+
test_connection(conn).should == 1
|
145
|
+
end
|
146
|
+
end
|
148
147
|
end
|
149
148
|
|
150
149
|
shared_examples_for 'a Connection with JDBC URL support' do
|
@@ -41,7 +41,7 @@ shared_examples_for 'supporting String' do
|
|
41
41
|
describe 'with manual typecasting' do
|
42
42
|
|
43
43
|
before do
|
44
|
-
@command = @connection.create_command("SELECT
|
44
|
+
@command = @connection.create_command("SELECT number_sold FROM widgets WHERE ad_description = ?")
|
45
45
|
@command.set_types(String)
|
46
46
|
@reader = @command.execute_reader('Buy this product now!')
|
47
47
|
@reader.next!
|
@@ -57,7 +57,7 @@ shared_examples_for 'supporting String' do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should return the correct result' do
|
60
|
-
@values.first.should == "
|
60
|
+
@values.first.should == "0"
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
data/lib/data_objects/version.rb
CHANGED
data/spec/pooling_spec.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 10
|
9
|
-
-
|
10
|
-
version: 0.10.
|
8
|
+
- 9
|
9
|
+
version: 0.10.9
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Dirkjan Bussink
|
@@ -15,17 +14,16 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-03-29 00:00:00
|
17
|
+
date: 2011-03-29 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: addressable
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
24
|
requirements:
|
26
25
|
- - ~>
|
27
26
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 1
|
29
27
|
segments:
|
30
28
|
- 2
|
31
29
|
- 1
|
@@ -36,11 +34,9 @@ dependencies:
|
|
36
34
|
name: rspec
|
37
35
|
prerelease: false
|
38
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
37
|
requirements:
|
41
38
|
- - ~>
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
hash: 9
|
44
40
|
segments:
|
45
41
|
- 2
|
46
42
|
- 5
|
@@ -51,11 +47,9 @@ dependencies:
|
|
51
47
|
name: yard
|
52
48
|
prerelease: false
|
53
49
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
50
|
requirements:
|
56
51
|
- - ~>
|
57
52
|
- !ruby/object:Gem::Version
|
58
|
-
hash: 1
|
59
53
|
segments:
|
60
54
|
- 0
|
61
55
|
- 5
|
@@ -135,6 +129,7 @@ files:
|
|
135
129
|
- tasks/spec.rake
|
136
130
|
- tasks/yard.rake
|
137
131
|
- tasks/yardstick.rake
|
132
|
+
has_rdoc: true
|
138
133
|
homepage: http://github.com/datamapper/do
|
139
134
|
licenses: []
|
140
135
|
|
@@ -144,27 +139,23 @@ rdoc_options: []
|
|
144
139
|
require_paths:
|
145
140
|
- lib
|
146
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
-
none: false
|
148
142
|
requirements:
|
149
143
|
- - ">="
|
150
144
|
- !ruby/object:Gem::Version
|
151
|
-
hash: 3
|
152
145
|
segments:
|
153
146
|
- 0
|
154
147
|
version: "0"
|
155
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
-
none: false
|
157
149
|
requirements:
|
158
150
|
- - ">="
|
159
151
|
- !ruby/object:Gem::Version
|
160
|
-
hash: 3
|
161
152
|
segments:
|
162
153
|
- 0
|
163
154
|
version: "0"
|
164
155
|
requirements: []
|
165
156
|
|
166
157
|
rubyforge_project: dorb
|
167
|
-
rubygems_version: 1.
|
158
|
+
rubygems_version: 1.3.6
|
168
159
|
signing_key:
|
169
160
|
specification_version: 3
|
170
161
|
summary: DataObjects basic API and shared driver specifications
|