nuodb 1.0.0.rc.1 → 1.0.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -1
- data/.rspec +2 -0
- data/AUTHORS +2 -2
- data/Gemfile +1 -5
- data/LICENSE +8 -9
- data/README.rdoc +21 -22
- data/Rakefile +42 -13
- data/ext/nuodb/atomic.c +11 -0
- data/ext/nuodb/atomic.h +62 -0
- data/ext/nuodb/extconf.rb +22 -1
- data/ext/nuodb/nuodb.cpp +2140 -753
- data/lib/nuodb/column.rb +131 -0
- data/lib/nuodb/error.rb +1 -29
- data/lib/nuodb/version.rb +1 -1
- data/nuodb.gemspec +26 -18
- data/spec/data/.gitignore +0 -0
- data/spec/functional/column_spec.rb +0 -0
- data/spec/functional/connection_spec.rb +110 -0
- data/spec/functional/datatypes_spec.rb +165 -0
- data/spec/functional/generated_keys_spec.rb +137 -0
- data/spec/functional/prepared_statement_spec.rb +160 -0
- data/spec/functional/statement_spec.rb +200 -0
- data/spec/functional/transaction_spec.rb +0 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/config.rb +42 -0
- data/spec/support/config.yml +10 -0
- data/spec/support/connection.rb +15 -0
- data/spec/support/datetime.rb +25 -0
- data/spec/unit/.gitignore +0 -0
- data/tasks/rdoc.rb +19 -0
- data/tasks/rspec.rb +56 -0
- data/tasks/stats.rb +24 -0
- metadata +253 -8
- data/COPYING +0 -25
- data/test/test_nuodb.rb +0 -267
data/COPYING
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
Copyright (c) 2012, NuoDB, Inc.
|
2
|
-
All rights reserved.
|
3
|
-
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
6
|
-
|
7
|
-
* Redistributions of source code must retain the above copyright
|
8
|
-
notice, this list of conditions and the following disclaimer.
|
9
|
-
* Redistributions in binary form must reproduce the above copyright
|
10
|
-
notice, this list of conditions and the following disclaimer in the
|
11
|
-
documentation and/or other materials provided with the distribution.
|
12
|
-
* Neither the name of NuoDB, Inc. nor the names of its contributors may
|
13
|
-
be used to endorse or promote products derived from this software
|
14
|
-
without specific prior written permission.
|
15
|
-
|
16
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
-
DISCLAIMED. IN NO EVENT SHALL NUODB, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
21
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
22
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
23
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
24
|
-
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
25
|
-
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/test/test_nuodb.rb
DELETED
@@ -1,267 +0,0 @@
|
|
1
|
-
#! /usr/local/bin/ruby
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2012, NuoDB, Inc.
|
5
|
-
# All rights reserved.
|
6
|
-
#
|
7
|
-
# Redistribution and use in source and binary forms, with or without
|
8
|
-
# modification, are permitted provided that the following conditions are met:
|
9
|
-
#
|
10
|
-
# * Redistributions of source code must retain the above copyright
|
11
|
-
# notice, this list of conditions and the following disclaimer.
|
12
|
-
# * Redistributions in binary form must reproduce the above copyright
|
13
|
-
# notice, this list of conditions and the following disclaimer in the
|
14
|
-
# documentation and/or other materials provided with the distribution.
|
15
|
-
# * Neither the name of NuoDB, Inc. nor the names of its contributors may
|
16
|
-
# be used to endorse or promote products derived from this software
|
17
|
-
# without specific prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
-
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
-
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
-
# DISCLAIMED. IN NO EVENT SHALL NUODB, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
23
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
25
|
-
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
27
|
-
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
28
|
-
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
#
|
30
|
-
|
31
|
-
require 'test/unit'
|
32
|
-
require 'ostruct'
|
33
|
-
require 'nuodb'
|
34
|
-
|
35
|
-
CONFIG = OpenStruct.new
|
36
|
-
CONFIG.database = ENV['NUODB_DATABASE'] || 'test@localhost'
|
37
|
-
CONFIG.schema = ENV['NUODB_SCHEMA'] || 'test'
|
38
|
-
CONFIG.username = ENV['NUODB_USERNAME'] || 'cloud'
|
39
|
-
CONFIG.password = ENV['NUODB_PASSWORD'] || 'user'
|
40
|
-
|
41
|
-
class TC_Nuodb < Test::Unit::TestCase
|
42
|
-
|
43
|
-
def setup()
|
44
|
-
@database = CONFIG.database
|
45
|
-
@schema = CONFIG.schema
|
46
|
-
@username = CONFIG.username
|
47
|
-
@password = CONFIG.password
|
48
|
-
end
|
49
|
-
|
50
|
-
def teardown()
|
51
|
-
end
|
52
|
-
|
53
|
-
#def test_version()
|
54
|
-
# con = NuoDB::Connection.createSqlConnection @database, @schema, @username, @password
|
55
|
-
# dmd = con.getMetaData
|
56
|
-
# assert_match /^1\./, dmd.getDatabaseVersion
|
57
|
-
#end
|
58
|
-
|
59
|
-
def test_select_from_dual()
|
60
|
-
con = NuoDB::Connection.createSqlConnection @database, @schema, @username, @password
|
61
|
-
stmt = con.createStatement
|
62
|
-
assert_not_nil stmt
|
63
|
-
have_result = stmt.execute "select 1 from dual"
|
64
|
-
assert_equal true, have_result
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_get_schema()
|
68
|
-
con = NuoDB::Connection.createSqlConnection @database, @schema, @username, @password
|
69
|
-
s = con.getSchema
|
70
|
-
assert_equal @schema.upcase, s
|
71
|
-
puts 'passed'
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_ping()
|
75
|
-
con = NuoDB::Connection.createSqlConnection @database, @schema, @username, @password
|
76
|
-
assert_equal true, con.ping
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_auto_commit_flag()
|
80
|
-
con = NuoDB::Connection.createSqlConnection @database, @schema, @username, @password
|
81
|
-
assert con.autocommit?
|
82
|
-
con.autocommit = false
|
83
|
-
assert !con.autocommit?
|
84
|
-
con.autocommit = true
|
85
|
-
assert con.autocommit?
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_statement()
|
89
|
-
con = NuoDB::Connection.createSqlConnection @database, @schema, @username, @password
|
90
|
-
stmt = con.createStatement
|
91
|
-
assert_not_nil stmt
|
92
|
-
have_result = stmt.execute "drop table test_nuodb if exists"
|
93
|
-
assert_equal false, have_result
|
94
|
-
assert_nil stmt.getResultSet
|
95
|
-
have_result = stmt.execute <<EOS
|
96
|
-
create table test_nuodb (
|
97
|
-
i integer,
|
98
|
-
d double,
|
99
|
-
s string,
|
100
|
-
b boolean,
|
101
|
-
x integer generated always,
|
102
|
-
primary key (i))
|
103
|
-
EOS
|
104
|
-
assert_equal false, have_result
|
105
|
-
assert_nil stmt.getResultSet
|
106
|
-
|
107
|
-
stmt = con.createStatement
|
108
|
-
assert_not_nil stmt
|
109
|
-
|
110
|
-
have_result = stmt.execute "select * from test_nuodb"
|
111
|
-
assert_equal true, have_result
|
112
|
-
assert_equal(-1, stmt.getUpdateCount)
|
113
|
-
assert_nil stmt.getGeneratedKeys
|
114
|
-
result = stmt.getResultSet
|
115
|
-
assert_not_nil result
|
116
|
-
assert_equal false, result.next
|
117
|
-
|
118
|
-
result = stmt.executeQuery "select * from test_nuodb"
|
119
|
-
assert_equal(-1, stmt.getUpdateCount)
|
120
|
-
assert_nil stmt.getGeneratedKeys
|
121
|
-
assert_not_nil result
|
122
|
-
assert_equal false, result.next
|
123
|
-
|
124
|
-
meta = result.getMetaData
|
125
|
-
assert_not_nil meta
|
126
|
-
assert_equal 5, meta.getColumnCount
|
127
|
-
|
128
|
-
assert_equal "I", meta.getColumnName(1)
|
129
|
-
assert_equal :SQL_INTEGER, meta.getType(1)
|
130
|
-
|
131
|
-
assert_equal "D", meta.getColumnName(2)
|
132
|
-
assert_equal :SQL_DOUBLE, meta.getType(2)
|
133
|
-
|
134
|
-
assert_equal "S", meta.getColumnName(3)
|
135
|
-
assert_equal :SQL_STRING, meta.getType(3)
|
136
|
-
|
137
|
-
assert_equal "B", meta.getColumnName(4)
|
138
|
-
assert_equal :SQL_BOOLEAN, meta.getType(4)
|
139
|
-
|
140
|
-
assert_equal "X", meta.getColumnName(5)
|
141
|
-
assert_equal :SQL_INTEGER, meta.getType(5)
|
142
|
-
|
143
|
-
have_result = stmt.execute "insert into test_nuodb(i,d,s,b) values(10,1.1,'one',true)"
|
144
|
-
assert_equal false, have_result
|
145
|
-
assert_nil stmt.getResultSet
|
146
|
-
assert_equal 1, stmt.getUpdateCount
|
147
|
-
k = stmt.getGeneratedKeys
|
148
|
-
assert_not_nil k
|
149
|
-
assert_equal true, k.next
|
150
|
-
assert k.getInteger(1) > 0
|
151
|
-
assert_equal false, k.next
|
152
|
-
|
153
|
-
have_result = stmt.execute "update test_nuodb set s='update' where i=999"
|
154
|
-
assert_equal false, have_result
|
155
|
-
assert_nil stmt.getResultSet
|
156
|
-
assert_equal(-1, stmt.getUpdateCount)
|
157
|
-
assert_nil stmt.getGeneratedKeys
|
158
|
-
|
159
|
-
have_result = stmt.execute "update test_nuodb set s='update' where i=10"
|
160
|
-
assert_equal false, have_result
|
161
|
-
assert_nil stmt.getResultSet
|
162
|
-
assert_equal 1, stmt.getUpdateCount
|
163
|
-
assert_nil stmt.getGeneratedKeys
|
164
|
-
|
165
|
-
r = stmt.executeQuery "select * from test_nuodb"
|
166
|
-
assert_not_nil r
|
167
|
-
assert_equal true, r.next
|
168
|
-
assert_equal 10, r.getInteger(1)
|
169
|
-
assert_equal 1.1, r.getDouble(2)
|
170
|
-
assert_equal 'update', r.getString(3)
|
171
|
-
assert_equal true, r.getBoolean(4)
|
172
|
-
|
173
|
-
assert_equal false, r.next
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_prepared_statement()
|
178
|
-
con = NuoDB::Connection.createSqlConnection @database, @schema, @username, @password
|
179
|
-
stmt = con.createStatement
|
180
|
-
assert_not_nil stmt
|
181
|
-
stmt.execute "drop table test_nuodb if exists"
|
182
|
-
stmt.execute <<EOS
|
183
|
-
create table test_nuodb (
|
184
|
-
i integer,
|
185
|
-
d double,
|
186
|
-
s string,
|
187
|
-
b boolean,
|
188
|
-
x integer generated always,
|
189
|
-
primary key (i))
|
190
|
-
EOS
|
191
|
-
|
192
|
-
insert = con.createPreparedStatement "insert into test_nuodb(i,d,s,b) values(?,?,?,?)"
|
193
|
-
|
194
|
-
insert.setInteger 1, 10
|
195
|
-
insert.setDouble 2, 1.1
|
196
|
-
insert.setString 3, 'one'
|
197
|
-
insert.setBoolean 4, true
|
198
|
-
insert.execute
|
199
|
-
k = insert.getGeneratedKeys
|
200
|
-
assert_not_nil k
|
201
|
-
assert k.next
|
202
|
-
assert k.getInteger(1) > 0
|
203
|
-
assert !k.next
|
204
|
-
|
205
|
-
#stmt.execute "insert into test_nuodb(i,d,s,b) values(10,1.1,'one',true)"
|
206
|
-
stmt.execute "insert into test_nuodb(i,d,s,b) values(20,2.2,'two',false)"
|
207
|
-
|
208
|
-
query = con.createPreparedStatement "select * from test_nuodb where i=?"
|
209
|
-
assert_not_nil query
|
210
|
-
assert_nil query.getGeneratedKeys
|
211
|
-
assert_equal(-1, query.getUpdateCount)
|
212
|
-
|
213
|
-
query.setInteger 1, 10
|
214
|
-
r = query.executeQuery
|
215
|
-
assert_nil query.getGeneratedKeys
|
216
|
-
assert_equal(-1, query.getUpdateCount)
|
217
|
-
assert_not_nil r
|
218
|
-
assert_equal true, r.next
|
219
|
-
assert_equal 10, r.getInteger(1)
|
220
|
-
assert_equal 1.1, r.getDouble(2)
|
221
|
-
assert_equal 'one', r.getString(3)
|
222
|
-
assert_equal true, r.getBoolean(4)
|
223
|
-
|
224
|
-
assert_equal false, r.next
|
225
|
-
|
226
|
-
query.setInteger 1, 20
|
227
|
-
r = query.executeQuery
|
228
|
-
assert_nil query.getGeneratedKeys
|
229
|
-
assert_not_nil r
|
230
|
-
assert_equal true, r.next
|
231
|
-
assert_equal 20, r.getInteger(1)
|
232
|
-
assert_equal 2.2, r.getDouble(2)
|
233
|
-
assert_equal 'two', r.getString(3)
|
234
|
-
assert_equal false, r.getBoolean(4)
|
235
|
-
|
236
|
-
assert_equal false, r.next
|
237
|
-
|
238
|
-
update = con.createPreparedStatement 'update test_nuodb set s=? where i=?'
|
239
|
-
assert_not_nil update
|
240
|
-
update.setString 1, 'change'
|
241
|
-
|
242
|
-
update.setInteger 2, 999
|
243
|
-
update.execute
|
244
|
-
assert_equal(-1, update.getUpdateCount)
|
245
|
-
|
246
|
-
update.setString 1, 'change'
|
247
|
-
update.setInteger 2, 20
|
248
|
-
update.execute
|
249
|
-
assert_equal 1, update.getUpdateCount
|
250
|
-
|
251
|
-
query.setInteger 1, 20
|
252
|
-
r = query.executeQuery
|
253
|
-
assert_not_nil r
|
254
|
-
assert_equal true, r.next
|
255
|
-
assert_equal 20, r.getInteger(1)
|
256
|
-
#assert_equal 'change', r.getString(3)
|
257
|
-
assert_equal -1, update.getUpdateCount
|
258
|
-
|
259
|
-
# todo rewrite these tests using rspec and clean up this mess
|
260
|
-
# also, just as i added to the AR side, have the rakefile set
|
261
|
-
# up the database for us, and have tables reset for each test
|
262
|
-
# and close connections.
|
263
|
-
|
264
|
-
end
|
265
|
-
|
266
|
-
end
|
267
|
-
|