data_objects 0.9.12 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{History.txt → HISTORY.markdown} +0 -0
- data/Manifest.txt +2 -2
- data/{README.txt → README.markdown} +2 -1
- data/Rakefile +2 -2
- data/lib/data_objects.rb +16 -17
- data/lib/data_objects/command.rb +2 -1
- data/lib/data_objects/connection.rb +8 -3
- data/lib/data_objects/error.rb +4 -0
- data/lib/data_objects/error/connection_error.rb +4 -0
- data/lib/data_objects/error/data_error.rb +4 -0
- data/lib/data_objects/error/integrity_error.rb +4 -0
- data/lib/data_objects/error/sql_error.rb +22 -0
- data/lib/data_objects/error/syntax_error.rb +4 -0
- data/lib/data_objects/error/transaction_error.rb +4 -0
- data/lib/data_objects/logger.rb +1 -1
- data/lib/data_objects/quoting.rb +2 -2
- data/lib/data_objects/spec/command_spec.rb +32 -1
- data/lib/data_objects/spec/connection_spec.rb +22 -0
- data/lib/data_objects/spec/encoding_spec.rb +15 -3
- data/lib/data_objects/spec/result_spec.rb +4 -1
- data/lib/data_objects/spec/typecast/bigdecimal_spec.rb +26 -1
- data/lib/data_objects/spec/typecast/boolean_spec.rb +24 -0
- data/lib/data_objects/spec/typecast/date_spec.rb +25 -1
- data/lib/data_objects/spec/typecast/datetime_spec.rb +28 -1
- data/lib/data_objects/spec/typecast/float_spec.rb +24 -1
- data/lib/data_objects/spec/typecast/nil_spec.rb +22 -7
- data/lib/data_objects/spec/typecast/time_spec.rb +25 -1
- data/lib/data_objects/transaction.rb +18 -8
- data/lib/data_objects/uri.rb +0 -1
- data/lib/data_objects/version.rb +1 -1
- data/spec/lib/ssl_helpers.rb +20 -0
- data/spec/spec_helper.rb +5 -1
- data/spec/transaction_spec.rb +1 -1
- data/tasks/gem.rake +1 -42
- data/tasks/release.rake +6 -6
- data/tasks/spec.rake +1 -0
- metadata +14 -6
File without changes
|
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -8,8 +8,8 @@ require 'lib/data_objects/version'
|
|
8
8
|
ROOT = Pathname(__FILE__).dirname.expand_path
|
9
9
|
JRUBY = RUBY_PLATFORM =~ /java/
|
10
10
|
WINDOWS = Gem.win_platform?
|
11
|
-
SUDO =
|
11
|
+
SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
|
12
12
|
|
13
|
-
Dir['tasks/*.rake'].each { |f| import f }
|
13
|
+
Dir['tasks/*.rake'].sort.each { |f| import f }
|
14
14
|
|
15
15
|
CLEAN.include(%w[ pkg/ **/*.rbc ])
|
data/lib/data_objects.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
gem 'extlib', '~>0.9.11'
|
4
1
|
require 'extlib'
|
5
2
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
require 'data_objects/version'
|
4
|
+
require 'data_objects/logger'
|
5
|
+
require 'data_objects/connection'
|
6
|
+
require 'data_objects/uri'
|
7
|
+
require 'data_objects/transaction'
|
8
|
+
require 'data_objects/command'
|
9
|
+
require 'data_objects/result'
|
10
|
+
require 'data_objects/reader'
|
11
|
+
require 'data_objects/quoting'
|
12
|
+
require 'data_objects/error'
|
13
|
+
require 'data_objects/error/sql_error'
|
14
|
+
require 'data_objects/error/connection_error'
|
15
|
+
require 'data_objects/error/data_error'
|
16
|
+
require 'data_objects/error/integrity_error'
|
17
|
+
require 'data_objects/error/syntax_error'
|
18
|
+
require 'data_objects/error/transaction_error'
|
data/lib/data_objects/command.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
1
|
begin
|
4
2
|
require 'fastthread'
|
5
3
|
rescue LoadError
|
@@ -40,7 +38,14 @@ module DataObjects
|
|
40
38
|
conn_uri = uri
|
41
39
|
end
|
42
40
|
|
43
|
-
|
41
|
+
# Exceptions to how a driver class is determined for a given URI
|
42
|
+
driver_class = if driver_name == 'sqlserver'
|
43
|
+
'SqlServer'
|
44
|
+
else
|
45
|
+
driver_name.capitalize
|
46
|
+
end
|
47
|
+
|
48
|
+
DataObjects.const_get(driver_class)::Connection.new(conn_uri)
|
44
49
|
end
|
45
50
|
|
46
51
|
# Ensure that all Connection subclasses handle pooling and logging uniformly.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module DataObjects
|
2
|
+
class SQLError < Error
|
3
|
+
|
4
|
+
attr_reader :message
|
5
|
+
attr_reader :code
|
6
|
+
attr_reader :sqlstate
|
7
|
+
attr_reader :query
|
8
|
+
attr_reader :uri
|
9
|
+
|
10
|
+
def initialize(message, code = nil, sqlstate = nil, query = nil, uri = nil)
|
11
|
+
@message = message
|
12
|
+
@code = code
|
13
|
+
@sqlstate = sqlstate
|
14
|
+
@query = query
|
15
|
+
@uri = uri
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
"#{message} (code: #{code}, sql state: #{sqlstate}, query: #{query}, uri: #{uri})"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/data_objects/logger.rb
CHANGED
data/lib/data_objects/quoting.rb
CHANGED
@@ -8,6 +8,7 @@ module DataObjects
|
|
8
8
|
|
9
9
|
case value
|
10
10
|
when Numeric then quote_numeric(value)
|
11
|
+
when ::Extlib::ByteArray then quote_byte_array(value)
|
11
12
|
when String then quote_string(value)
|
12
13
|
when Time then quote_time(value)
|
13
14
|
when DateTime then quote_datetime(value)
|
@@ -17,7 +18,6 @@ module DataObjects
|
|
17
18
|
when Range then quote_range(value)
|
18
19
|
when Symbol then quote_symbol(value)
|
19
20
|
when Regexp then quote_regexp(value)
|
20
|
-
when ::Extlib::ByteArray then quote_byte_array(value)
|
21
21
|
when Class then quote_class(value)
|
22
22
|
else
|
23
23
|
if value.respond_to?(:to_sql)
|
@@ -91,7 +91,7 @@ module DataObjects
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def quote_byte_array(value)
|
94
|
-
quote_string(value
|
94
|
+
quote_string(value)
|
95
95
|
end
|
96
96
|
|
97
97
|
end
|
@@ -52,6 +52,18 @@ share_examples_for 'a Command' do
|
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
+
describe 'with a valid statement and ? inside quotes' do
|
56
|
+
|
57
|
+
before :each do
|
58
|
+
@command_with_quotes = @connection.create_command("INSERT INTO users (name) VALUES ('will it work? ')")
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should not raise an error' do
|
62
|
+
lambda { @command_with_quotes.execute_non_query }.should_not raise_error
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
55
67
|
end
|
56
68
|
|
57
69
|
it { @command.should respond_to(:execute_reader) }
|
@@ -86,6 +98,19 @@ share_examples_for 'a Command' do
|
|
86
98
|
|
87
99
|
end
|
88
100
|
|
101
|
+
describe 'with a valid reader and ? inside column alias' do
|
102
|
+
|
103
|
+
before :each do
|
104
|
+
@reader_with_quotes = @connection.create_command("SELECT code AS \"code?\", name FROM widgets WHERE ad_description = ?")
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should not raise an error' do
|
108
|
+
lambda { @reader_with_quotes.execute_reader(nil) }.should_not raise_error
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
|
89
114
|
end
|
90
115
|
|
91
116
|
it { @command.should respond_to(:set_types) }
|
@@ -168,7 +193,13 @@ share_examples_for 'a Command with async' do
|
|
168
193
|
threads << Thread.new do
|
169
194
|
connection = DataObjects::Connection.new(CONFIG.uri)
|
170
195
|
command = connection.create_command(CONFIG.sleep)
|
171
|
-
|
196
|
+
if CONFIG.sleep =~ /^SELECT/i
|
197
|
+
reader = command.execute_reader
|
198
|
+
reader.next!
|
199
|
+
reader.close
|
200
|
+
else
|
201
|
+
result = command.execute_non_query
|
202
|
+
end
|
172
203
|
connection.close
|
173
204
|
end
|
174
205
|
end
|
@@ -104,3 +104,25 @@ share_examples_for 'a Connection with authentication support' do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
end
|
107
|
+
|
108
|
+
share_examples_for 'a Connection with SSL support' do
|
109
|
+
|
110
|
+
if DataObjectsSpecHelpers.test_environment_supports_ssl?
|
111
|
+
describe 'connecting with SSL' do
|
112
|
+
|
113
|
+
it 'should connect securely' do
|
114
|
+
DataObjects::Connection.new("#{CONFIG.uri}?#{CONFIG.ssl}").secure?.should be_true
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'connecting without SSL' do
|
121
|
+
|
122
|
+
it 'should not connect securely' do
|
123
|
+
DataObjects::Connection.new(CONFIG.uri).secure?.should be_false
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
@@ -14,18 +14,30 @@ share_examples_for 'a driver supporting encodings' do
|
|
14
14
|
describe 'character_set' do
|
15
15
|
|
16
16
|
it 'uses utf8 by default' do
|
17
|
-
@connection.character_set.should == '
|
17
|
+
@connection.character_set.should == 'UTF-8'
|
18
18
|
end
|
19
19
|
|
20
20
|
describe 'sets the character set through the URI' do
|
21
21
|
before do
|
22
|
-
@latin1_connection = DataObjects::Connection.new("#{CONFIG.
|
22
|
+
# @latin1_connection = DataObjects::Connection.new("#{CONFIG.uri}?encoding=latin1")
|
23
|
+
@latin1_connection = DataObjects::Connection.new("#{CONFIG.scheme}://#{CONFIG.user}:#{CONFIG.pass}@#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}?encoding=ISO-8859-1")
|
23
24
|
end
|
24
25
|
|
25
26
|
after { @latin1_connection.close }
|
26
27
|
|
27
|
-
it { @latin1_connection.character_set.should == '
|
28
|
+
it { @latin1_connection.character_set.should == 'ISO-8859-1' }
|
28
29
|
end
|
29
30
|
|
31
|
+
describe 'uses UTF-8 when an invalid encoding is given' do
|
32
|
+
before do
|
33
|
+
@latin1_connection = DataObjects::Connection.new("#{CONFIG.scheme}://#{CONFIG.user}:#{CONFIG.pass}@#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}?encoding=ISO-INVALID")
|
34
|
+
end
|
35
|
+
|
36
|
+
after { @latin1_connection.close }
|
37
|
+
|
38
|
+
it { @latin1_connection.character_set.should == 'UTF-8' }
|
39
|
+
end
|
40
|
+
|
41
|
+
|
30
42
|
end
|
31
43
|
end
|
@@ -37,7 +37,10 @@ share_examples_for 'a Result which returns inserted keys' do
|
|
37
37
|
|
38
38
|
before :each do
|
39
39
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
40
|
-
|
40
|
+
command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
|
41
|
+
# execute the command twice and expose the second result
|
42
|
+
command.execute_non_query("monkey")
|
43
|
+
@result = command.execute_non_query("monkey")
|
41
44
|
end
|
42
45
|
|
43
46
|
after :each do
|
@@ -35,7 +35,32 @@ share_examples_for 'supporting BigDecimal' do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'should return the correct result' do
|
38
|
-
|
38
|
+
# rounding seems necessary for the jruby do_derby driver
|
39
|
+
@values.first.round(2).should == 10.23
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'with manual typecasting a nil value' do
|
45
|
+
|
46
|
+
before do
|
47
|
+
@command = @connection.create_command("SELECT cost2 FROM widgets WHERE id = ?")
|
48
|
+
@command.set_types(BigDecimal)
|
49
|
+
@reader = @command.execute_reader(6)
|
50
|
+
@reader.next!
|
51
|
+
@values = @reader.values
|
52
|
+
end
|
53
|
+
|
54
|
+
after do
|
55
|
+
@reader.close
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should return the correctly typed result' do
|
59
|
+
@values.first.should be_kind_of(NilClass)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should return the correct result' do
|
63
|
+
@values.first.should be_nil
|
39
64
|
end
|
40
65
|
|
41
66
|
end
|
@@ -40,6 +40,30 @@ share_examples_for 'supporting Boolean' do
|
|
40
40
|
|
41
41
|
end
|
42
42
|
|
43
|
+
describe 'with manual typecasting a nil value' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
@command = @connection.create_command("SELECT flags FROM widgets WHERE id = ?")
|
47
|
+
@command.set_types(TrueClass)
|
48
|
+
@reader = @command.execute_reader(4)
|
49
|
+
@reader.next!
|
50
|
+
@values = @reader.values
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
@reader.close
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should return the correctly typed result' do
|
58
|
+
@values.first.should be_kind_of(NilClass)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should return the correct result' do
|
62
|
+
@values.first.should be_nil
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
43
67
|
end
|
44
68
|
|
45
69
|
describe 'writing an Boolean' do
|
@@ -40,12 +40,36 @@ share_examples_for 'supporting Date' do
|
|
40
40
|
|
41
41
|
end
|
42
42
|
|
43
|
+
describe 'with manual typecasting a nil value' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
@command = @connection.create_command("SELECT release_date FROM widgets WHERE id = ?")
|
47
|
+
@command.set_types(Date)
|
48
|
+
@reader = @command.execute_reader(7)
|
49
|
+
@reader.next!
|
50
|
+
@values = @reader.values
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
@reader.close
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should return a nil class' do
|
58
|
+
@values.first.should be_kind_of(NilClass)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should return nil' do
|
62
|
+
@values.first.should be_nil
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
43
67
|
end
|
44
68
|
|
45
69
|
describe 'writing an Date' do
|
46
70
|
|
47
71
|
before do
|
48
|
-
@reader = @connection.create_command("SELECT id FROM widgets WHERE release_date = ?").execute_reader(Date.civil(2008, 2, 14))
|
72
|
+
@reader = @connection.create_command("SELECT id FROM widgets WHERE release_date = ? ORDER BY id").execute_reader(Date.civil(2008, 2, 14))
|
49
73
|
@reader.next!
|
50
74
|
@values = @reader.values
|
51
75
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
JRUBY = RUBY_PLATFORM =~ /java/ unless defined?(JRUBY)
|
2
|
+
|
1
3
|
share_examples_for 'supporting DateTime' do
|
2
4
|
|
3
5
|
include DataObjectsSpecHelpers
|
@@ -41,12 +43,37 @@ share_examples_for 'supporting DateTime' do
|
|
41
43
|
|
42
44
|
end
|
43
45
|
|
46
|
+
describe 'with manual typecasting a nil value' do
|
47
|
+
|
48
|
+
before do
|
49
|
+
@command = @connection.create_command("SELECT release_datetime FROM widgets WHERE id = ?")
|
50
|
+
@command.set_types(DateTime)
|
51
|
+
@reader = @command.execute_reader(8)
|
52
|
+
@reader.next!
|
53
|
+
@values = @reader.values
|
54
|
+
end
|
55
|
+
|
56
|
+
after do
|
57
|
+
@reader.close
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should return a nil class' do
|
61
|
+
@values.first.should be_kind_of(NilClass)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should return nil' do
|
65
|
+
@values.first.should be_nil
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
44
70
|
end
|
45
71
|
|
46
72
|
describe 'writing an DateTime' do
|
47
73
|
|
48
74
|
before do
|
49
|
-
|
75
|
+
local_offset = Rational(Time.local(2008, 2, 14).utc_offset, 86400)
|
76
|
+
@reader = @connection.create_command("SELECT id FROM widgets WHERE release_datetime = ? ORDER BY id").execute_reader(DateTime.civil(2008, 2, 14, 00, 31, 12, local_offset))
|
50
77
|
@reader.next!
|
51
78
|
@values = @reader.values
|
52
79
|
end
|
@@ -41,6 +41,29 @@ share_examples_for 'supporting Float' do
|
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
|
+
describe 'with manual typecasting a nil' do
|
45
|
+
|
46
|
+
before do
|
47
|
+
@command = @connection.create_command("SELECT cost1 FROM widgets WHERE id = ?")
|
48
|
+
@command.set_types(Float)
|
49
|
+
@reader = @command.execute_reader(5)
|
50
|
+
@reader.next!
|
51
|
+
@values = @reader.values
|
52
|
+
end
|
53
|
+
|
54
|
+
after do
|
55
|
+
@reader.close
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should return the correctly typed result' do
|
59
|
+
@values.first.should be_kind_of(NilClass)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should return the correct result' do
|
63
|
+
@values.first.should be_nil
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
44
67
|
end
|
45
68
|
|
46
69
|
describe 'writing an Float' do
|
@@ -101,7 +124,7 @@ share_examples_for 'supporting Float autocasting' do
|
|
101
124
|
|
102
125
|
it 'should return the correct result' do
|
103
126
|
@values.first.should == 13.4
|
104
|
-
@values.last.should == 10.23
|
127
|
+
BigDecimal.new(@values.last.to_s).round(2).should == 10.23
|
105
128
|
end
|
106
129
|
|
107
130
|
end
|
@@ -46,23 +46,38 @@ end
|
|
46
46
|
|
47
47
|
share_examples_for 'supporting writing an Nil' do
|
48
48
|
|
49
|
-
|
49
|
+
include DataObjectsSpecHelpers
|
50
|
+
|
51
|
+
before :all do
|
52
|
+
setup_test_environment
|
53
|
+
end
|
54
|
+
|
55
|
+
before :each do
|
56
|
+
@connection = DataObjects::Connection.new(CONFIG.uri)
|
57
|
+
end
|
58
|
+
|
59
|
+
after :each do
|
60
|
+
@connection.close
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
describe 'supporting writing an Nil' do
|
65
|
+
# see as an example oracle
|
66
|
+
# http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements005.htm#sthref487
|
67
|
+
# http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions013.htm#i1050801
|
50
68
|
|
51
69
|
describe 'as a parameter' do
|
52
70
|
|
53
71
|
before do
|
54
|
-
@reader = @connection.create_command("SELECT id FROM widgets WHERE ad_description
|
55
|
-
|
56
|
-
@values = @reader.values
|
57
|
-
end
|
72
|
+
@reader = @connection.create_command("SELECT id FROM widgets WHERE ad_description IN (?) ORDER BY id").execute_reader(nil)
|
73
|
+
end
|
58
74
|
|
59
75
|
after do
|
60
76
|
@reader.close
|
61
77
|
end
|
62
78
|
|
63
79
|
it 'should return the correct entry' do
|
64
|
-
|
65
|
-
@values.first.should satisfy { |val| val == 3 or val == 2 }
|
80
|
+
@reader.next!.should be_false
|
66
81
|
end
|
67
82
|
|
68
83
|
end
|
@@ -40,12 +40,36 @@ share_examples_for 'supporting Time' do
|
|
40
40
|
|
41
41
|
end
|
42
42
|
|
43
|
+
describe 'with manual typecasting a nil value' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
@command = @connection.create_command("SELECT release_timestamp FROM widgets WHERE id = ?")
|
47
|
+
@command.set_types(Time)
|
48
|
+
@reader = @command.execute_reader(9)
|
49
|
+
@reader.next!
|
50
|
+
@values = @reader.values
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
@reader.close
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should return a nil class' do
|
58
|
+
@values.first.should be_kind_of(NilClass)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should return nil' do
|
62
|
+
@values.first.should be_nil
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
43
67
|
end
|
44
68
|
|
45
69
|
describe 'writing an Time' do
|
46
70
|
|
47
71
|
before do
|
48
|
-
@reader = @connection.create_command("SELECT id FROM widgets WHERE release_datetime = ?").execute_reader(Time.
|
72
|
+
@reader = @connection.create_command("SELECT id FROM widgets WHERE release_datetime = ? ORDER BY id").execute_reader(Time.local(2008, 2, 14, 00, 31, 12))
|
49
73
|
@reader.next!
|
50
74
|
@values = @reader.values
|
51
75
|
end
|
@@ -33,16 +33,26 @@ module DataObjects
|
|
33
33
|
@connection.close
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
def
|
42
|
-
|
36
|
+
def begin
|
37
|
+
cmd = "BEGIN"
|
38
|
+
connection.create_command(cmd).execute_non_query
|
39
|
+
end
|
40
|
+
|
41
|
+
def commit
|
42
|
+
cmd = "COMMIT"
|
43
|
+
connection.create_command(cmd).execute_non_query
|
44
|
+
end
|
45
|
+
|
46
|
+
def rollback
|
47
|
+
cmd = "ROLLBACK"
|
48
|
+
connection.create_command(cmd).execute_non_query
|
49
|
+
end
|
50
|
+
|
43
51
|
def prepare; not_implemented; end;
|
44
|
-
|
52
|
+
def begin_prepared; not_implemented; end;
|
53
|
+
def commit_prepared; not_implemented; end;
|
45
54
|
def rollback_prepared; not_implemented; end;
|
55
|
+
def prepare; not_implemented; end;
|
46
56
|
|
47
57
|
private
|
48
58
|
def not_implemented
|
data/lib/data_objects/uri.rb
CHANGED
data/lib/data_objects/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module SSLHelpers
|
4
|
+
|
5
|
+
CERTS_DIR = Pathname(__FILE__).dirname.join('ssl_certs').to_s
|
6
|
+
|
7
|
+
CONFIG = OpenStruct.new
|
8
|
+
CONFIG.ca_cert = CERTS_DIR / 'ca-cert.pem'
|
9
|
+
CONFIG.ca_key = CERTS_DIR / 'ca-key.pem'
|
10
|
+
CONFIG.server_cert = CERTS_DIR / 'server-cert.pem'
|
11
|
+
CONFIG.server_key = CERTS_DIR / 'server-key.pem'
|
12
|
+
CONFIG.client_cert = CERTS_DIR / 'client-cert.pem'
|
13
|
+
CONFIG.client_key = CERTS_DIR / 'client-key.pem'
|
14
|
+
CONFIG.cipher = 'AES128-SHA'
|
15
|
+
|
16
|
+
def self.query(*keys)
|
17
|
+
keys.map { |key| "ssl[#{key}]=#{CGI::escape(CONFIG.send(key))}" }.join('&')
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'spec'
|
3
3
|
|
4
|
-
|
4
|
+
dir = File.dirname(__FILE__)
|
5
|
+
lib_path = File.expand_path("#{dir}/../lib")
|
6
|
+
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
7
|
+
require 'data_objects'
|
8
|
+
|
5
9
|
require File.expand_path(File.join(File.dirname(__FILE__), 'do_mock'))
|
data/spec/transaction_spec.rb
CHANGED
@@ -30,7 +30,7 @@ describe DataObjects::Transaction do
|
|
30
30
|
@transaction.close
|
31
31
|
end
|
32
32
|
end
|
33
|
-
[:
|
33
|
+
[:prepare, :commit_prepared, :rollback_prepared].each do |meth|
|
34
34
|
it "should raise NotImplementedError on #{meth}" do
|
35
35
|
lambda do @transaction.send(meth) end.should raise_error(NotImplementedError)
|
36
36
|
end
|
data/tasks/gem.rake
CHANGED
@@ -1,49 +1,8 @@
|
|
1
1
|
require 'rubygems/package_task'
|
2
2
|
|
3
|
-
GEM_SPEC =
|
4
|
-
# basic information
|
5
|
-
s.name = "data_objects"
|
6
|
-
s.version = DataObjects::VERSION
|
7
|
-
s.platform = Gem::Platform::RUBY
|
8
|
-
|
9
|
-
# description and details
|
10
|
-
s.summary = 'DataObjects basic API and shared driver specifications'
|
11
|
-
s.description = "Provide a standard and simplified API for communicating with RDBMS from Ruby"
|
12
|
-
|
13
|
-
# dependencies
|
14
|
-
s.add_dependency "addressable", "~>2.0.0"
|
15
|
-
s.add_dependency "extlib", "~>0.9.12"
|
16
|
-
|
17
|
-
# development dependencies
|
18
|
-
s.add_development_dependency 'rspec', '~>1.2.0'
|
19
|
-
|
20
|
-
# components, files and paths
|
21
|
-
s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake",
|
22
|
-
"LICENSE", "Rakefile", "*.{rdoc,txt,yml}"]
|
23
|
-
|
24
|
-
s.require_path = 'lib'
|
25
|
-
|
26
|
-
# documentation
|
27
|
-
s.has_rdoc = false
|
28
|
-
|
29
|
-
# project information
|
30
|
-
s.homepage = 'http://github.com/datamapper/do'
|
31
|
-
s.rubyforge_project = 'dorb'
|
32
|
-
|
33
|
-
# author and contributors
|
34
|
-
s.author = 'Dirkjan Bussink'
|
35
|
-
s.email = 'd.bussink@gmail.com'
|
36
|
-
end
|
3
|
+
GEM_SPEC = eval(File.read('data_objects.gemspec'))
|
37
4
|
|
38
5
|
gem_package = Gem::PackageTask.new(GEM_SPEC) do |pkg|
|
39
6
|
pkg.need_tar = false
|
40
7
|
pkg.need_zip = false
|
41
8
|
end
|
42
|
-
|
43
|
-
file "#{GEM_SPEC.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
|
44
|
-
puts "Generating #{t.name}"
|
45
|
-
File.open(t.name, 'w') { |f| f.puts GEM_SPEC.to_yaml }
|
46
|
-
end
|
47
|
-
|
48
|
-
desc "Generate or update the standalone gemspec file for the project"
|
49
|
-
task :gemspec => ["#{GEM_SPEC.name}.gemspec"]
|
data/tasks/release.rake
CHANGED
@@ -26,19 +26,19 @@ if defined?(RubyForge) then
|
|
26
26
|
|
27
27
|
# read project info and overview
|
28
28
|
notes = begin
|
29
|
-
r = File.read("README.
|
30
|
-
r.split(/^(
|
29
|
+
r = File.read("README.markdown")
|
30
|
+
r.split(/^(.*\n\-+)/)[1..4].join.strip
|
31
31
|
rescue
|
32
|
-
warn "Missing README.
|
32
|
+
warn "Missing README.markdown"
|
33
33
|
''
|
34
34
|
end
|
35
35
|
|
36
36
|
# read changes
|
37
37
|
changes = begin
|
38
|
-
h = File.read("
|
39
|
-
h.split(/^(
|
38
|
+
h = File.read("HISTORY.markdown")
|
39
|
+
h.split(/^(##+ .*)/)[1..2].join.strip
|
40
40
|
rescue
|
41
|
-
warn "Missing
|
41
|
+
warn "Missing HISTORY.markdown"
|
42
42
|
''
|
43
43
|
end
|
44
44
|
|
data/tasks/spec.rake
CHANGED
@@ -5,6 +5,7 @@ desc 'Run specifications'
|
|
5
5
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
6
6
|
t.spec_opts << '--options' << ROOT + 'spec/spec.opts'
|
7
7
|
t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb').map { |f| f.to_s }
|
8
|
+
t.libs << 'lib'
|
8
9
|
|
9
10
|
begin
|
10
11
|
# RCov is run by default, except on the JRuby platform
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dirkjan Bussink
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-16 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.0
|
23
|
+
version: "2.0"
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: extlib
|
@@ -53,6 +53,13 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- lib/data_objects/command.rb
|
55
55
|
- lib/data_objects/connection.rb
|
56
|
+
- lib/data_objects/error/connection_error.rb
|
57
|
+
- lib/data_objects/error/data_error.rb
|
58
|
+
- lib/data_objects/error/integrity_error.rb
|
59
|
+
- lib/data_objects/error/sql_error.rb
|
60
|
+
- lib/data_objects/error/syntax_error.rb
|
61
|
+
- lib/data_objects/error/transaction_error.rb
|
62
|
+
- lib/data_objects/error.rb
|
56
63
|
- lib/data_objects/logger.rb
|
57
64
|
- lib/data_objects/quoting.rb
|
58
65
|
- lib/data_objects/reader.rb
|
@@ -86,6 +93,7 @@ files:
|
|
86
93
|
- spec/do_mock.rb
|
87
94
|
- spec/lib/pending_helpers.rb
|
88
95
|
- spec/lib/rspec_immediate_feedback_formatter.rb
|
96
|
+
- spec/lib/ssl_helpers.rb
|
89
97
|
- spec/reader_spec.rb
|
90
98
|
- spec/result_spec.rb
|
91
99
|
- spec/spec_helper.rb
|
@@ -97,9 +105,9 @@ files:
|
|
97
105
|
- tasks/spec.rake
|
98
106
|
- LICENSE
|
99
107
|
- Rakefile
|
100
|
-
-
|
108
|
+
- HISTORY.markdown
|
109
|
+
- README.markdown
|
101
110
|
- Manifest.txt
|
102
|
-
- README.txt
|
103
111
|
has_rdoc: true
|
104
112
|
homepage: http://github.com/datamapper/do
|
105
113
|
licenses: []
|
@@ -124,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
132
|
requirements: []
|
125
133
|
|
126
134
|
rubyforge_project: dorb
|
127
|
-
rubygems_version: 1.3.
|
135
|
+
rubygems_version: 1.3.4
|
128
136
|
signing_key:
|
129
137
|
specification_version: 3
|
130
138
|
summary: DataObjects basic API and shared driver specifications
|