sqlite3-ruby 0.9.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sqlite3-ruby might be problematic. Click here for more details.

@@ -0,0 +1,89 @@
1
+ #--
2
+ # =============================================================================
3
+ # Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
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
+ #
16
+ # * The names of its contributors may not be used to endorse or promote
17
+ # products derived from this software without specific prior written
18
+ # permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
24
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ # =============================================================================
31
+ #++
32
+
33
+ require 'sqlite3/constants'
34
+
35
+ module SQLite3
36
+
37
+ class Value
38
+ attr_reader :handle
39
+
40
+ def initialize( db, handle )
41
+ @driver = db.driver
42
+ @handle = handle
43
+ end
44
+
45
+ def null?
46
+ type == :null
47
+ end
48
+
49
+ def to_blob
50
+ @driver.value_blob( @handle )
51
+ end
52
+
53
+ def length( utf16=false )
54
+ if utf16
55
+ @driver.value_bytes16( @handle )
56
+ else
57
+ @driver.value_bytes( @handle )
58
+ end
59
+ end
60
+
61
+ def to_f
62
+ @driver.value_double( @handle )
63
+ end
64
+
65
+ def to_i
66
+ @driver.value_int( @handle )
67
+ end
68
+
69
+ def to_int64
70
+ @driver.value_int64( @handle )
71
+ end
72
+
73
+ def to_s( utf16=false )
74
+ @driver.value_text( @handle, utf16 )
75
+ end
76
+
77
+ def type
78
+ case @driver.value_type( @handle )
79
+ when Constants::ColumnType::INTEGER then :int
80
+ when Constants::ColumnType::FLOAT then :float
81
+ when Constants::ColumnType::TEXT then :text
82
+ when Constants::ColumnType::BLOB then :blob
83
+ when Constants::ColumnType::NULL then :null
84
+ end
85
+ end
86
+
87
+ end
88
+
89
+ end
@@ -0,0 +1,45 @@
1
+ #--
2
+ # =============================================================================
3
+ # Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
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
+ #
16
+ # * The names of its contributors may not be used to endorse or promote
17
+ # products derived from this software without specific prior written
18
+ # permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
24
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ # =============================================================================
31
+ #++
32
+
33
+ module SQLite3
34
+
35
+ module Version
36
+
37
+ MAJOR = 0
38
+ MINOR = 9
39
+ TINY = 0
40
+
41
+ STRING = [ MAJOR, MINOR, TINY ].join( "." )
42
+
43
+ end
44
+
45
+ end
Binary file
data/test/bm.rb ADDED
@@ -0,0 +1,140 @@
1
+ require 'benchmark'
2
+
3
+ N = 1000
4
+
5
+ $VERBOSE=nil
6
+
7
+ puts "file require"
8
+ Benchmark.bm( 7 ) do |x|
9
+ x.report('sqlite') do
10
+ N.times do
11
+ $".delete_if { |i| i =~ /sqlite/ }
12
+ require 'sqlite'
13
+ end
14
+ end
15
+ x.report('sqlite3') do
16
+ N.times do
17
+ $".delete_if { |i| i =~ /sqlite3/ }
18
+ require 'sqlite3'
19
+ end
20
+ end
21
+ end
22
+
23
+ puts
24
+ puts "database creation..."
25
+ Benchmark.bm( 7 ) do |x|
26
+ x.report('sqlite') do
27
+ N.times do
28
+ File.delete "test.db" rescue nil
29
+ SQLite::Database.open( "test.db" ).close
30
+ end
31
+ end
32
+ x.report('sqlite3') do
33
+ N.times do
34
+ File.delete "test.db" rescue nil
35
+ SQLite3::Database.open( "test.db" ).close
36
+ end
37
+ end
38
+ end
39
+ File.delete "test.db" rescue nil
40
+
41
+ SQLite::Database.open( "test.db" ).close
42
+ SQLite3::Database.open( "test3.db" ).close
43
+
44
+ puts
45
+ puts "database open..."
46
+ Benchmark.bm( 7 ) do |x|
47
+ x.report('sqlite') do
48
+ N.times do
49
+ SQLite::Database.open( "test.db" ).close
50
+ end
51
+ end
52
+ x.report('sqlite3') do
53
+ N.times do
54
+ SQLite3::Database.open( "test3.db" ).close
55
+ end
56
+ end
57
+ end
58
+ File.delete "test.db" rescue nil
59
+ File.delete "test3.db" rescue nil
60
+
61
+ db = SQLite::Database.open( "test.db" )
62
+ db3 = SQLite3::Database.open( "test3.db" )
63
+
64
+ db.execute "create table foo (a,b)"
65
+ db3.execute "create table foo (a,b)"
66
+
67
+ puts
68
+ puts "insertions"
69
+ Benchmark.bm( 7 ) do |x|
70
+ x.report('sqlite') do
71
+ db.transaction do
72
+ N.times do |i|
73
+ db.execute "insert into foo values (#{i}, #{i+1})"
74
+ end
75
+ end
76
+ end
77
+ x.report('sqlite3') do
78
+ db3.transaction do
79
+ N.times do |i|
80
+ db3.execute "insert into foo values (#{i}, #{i+1})"
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ puts
87
+ puts "insertions using prepared statement"
88
+ Benchmark.bm( 7 ) do |x|
89
+ x.report('sqlite') do
90
+ db.transaction do
91
+ stmt = db.prepare "insert into foo values (?,?)"
92
+ N.times { |i| stmt.execute i, i+1 }
93
+ end
94
+ end
95
+ x.report('sqlite3') do
96
+ db3.transaction do
97
+ db3.prepare( "insert into foo values (?,?)" ) do |stmt|
98
+ N.times { |i| stmt.execute i, i+1 }
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ db.close
105
+ db3.close
106
+ File.delete "test.db" rescue nil
107
+ File.delete "test3.db" rescue nil
108
+
109
+ db = SQLite::Database.open( "test.db" )
110
+ db3 = SQLite3::Database.open( "test3.db" )
111
+
112
+ db.execute "create table foo (a,b)"
113
+ db.execute "insert into foo values (1,2)"
114
+ db.execute "insert into foo values (3,4)"
115
+ db.execute "insert into foo values (5,6)"
116
+
117
+ db3.execute "create table foo (a,b)"
118
+ db3.execute "insert into foo values (1,2)"
119
+ db3.execute "insert into foo values (3,4)"
120
+ db3.execute "insert into foo values (5,6)"
121
+
122
+ puts
123
+ puts "queries"
124
+ Benchmark.bm( 7 ) do |x|
125
+ x.report('sqlite') do
126
+ N.times do
127
+ db.execute "select * from foo"
128
+ end
129
+ end
130
+ x.report('sqlite3') do
131
+ N.times do
132
+ db3.execute "select * from foo"
133
+ end
134
+ end
135
+ end
136
+
137
+ db.close
138
+ db3.close
139
+ File.delete "test.db" rescue nil
140
+ File.delete "test3.db" rescue nil
@@ -0,0 +1,322 @@
1
+ #--
2
+ # =============================================================================
3
+ # Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
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
+ #
16
+ # * The names of its contributors may not be used to endorse or promote
17
+ # products derived from this software without specific prior written
18
+ # permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
24
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ # =============================================================================
31
+ #++
32
+
33
+ $:.unshift "../../../lib"
34
+
35
+ require 'sqlite3/constants'
36
+ require 'sqlite3/driver/dl/driver'
37
+ require 'test/unit'
38
+
39
+ class TC_DL_Driver < Test::Unit::TestCase
40
+
41
+ def utf16ify( str )
42
+ chars = str.split(//)
43
+ chars.zip(["\0"] * chars.length).flatten.join
44
+ end
45
+
46
+ def setup
47
+ @driver = SQLite3::Driver::DL::Driver.new
48
+ @dbname = "test.db"
49
+ @db = nil
50
+ end
51
+
52
+ def teardown
53
+ @driver.close( @db ) rescue nil
54
+ File.delete @dbname rescue nil
55
+ end
56
+
57
+ def test_open
58
+ result, @db = @driver.open( @dbname )
59
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
60
+ assert File.exist?( @dbname )
61
+ end
62
+
63
+ def test_open_utf16
64
+ name = utf16ify( @dbname )
65
+ result, @db = @driver.open( name, true )
66
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
67
+ assert File.exist?( @dbname )
68
+ end
69
+
70
+ def test_errmsg
71
+ result, @db = @driver.open( @dbname )
72
+ msg = @driver.errmsg( @db )
73
+ assert_equal msg, "not an error"
74
+ end
75
+
76
+ def test_errmsg16
77
+ result, @db = @driver.open( @dbname )
78
+ msg = @driver.errmsg( @db, true )
79
+ assert_equal msg, utf16ify( "not an error" )
80
+ end
81
+
82
+ def test_prepare
83
+ result, @db = @driver.open( @dbname )
84
+ sql = "create table foo ( a, b )"
85
+ result, handle, remainder = @driver.prepare( @db, sql )
86
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
87
+ assert_equal "", remainder
88
+ @driver.finalize( handle )
89
+ end
90
+
91
+ def test_prepare_error
92
+ result, @db = @driver.open( @dbname )
93
+ sql = "create tble foo ( a, b )"
94
+ result, handle, remainder = @driver.prepare( @db, sql )
95
+ assert_equal SQLite3::Constants::ErrorCode::ERROR, result
96
+ end
97
+
98
+ def test_prepare_remainder
99
+ result, @db = @driver.open( @dbname )
100
+ sql = "create table foo ( a, b ); select * from foo"
101
+ result, handle, remainder = @driver.prepare( @db, sql )
102
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
103
+ assert_equal " select * from foo", remainder
104
+ @driver.finalize( handle )
105
+ end
106
+
107
+ def test_prepare16
108
+ result, @db = @driver.open( @dbname )
109
+ sql = utf16ify( "create table foo ( a, b )" )
110
+ result, handle, remainder = @driver.prepare( @db, sql, true )
111
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
112
+ assert_equal "", remainder
113
+ @driver.finalize( handle )
114
+ end
115
+
116
+ def test_prepare16_remainder
117
+ result, @db = @driver.open( @dbname )
118
+ sql = utf16ify( "create table foo ( a, b ); select * from foo" )
119
+ result, handle, remainder = @driver.prepare( @db, sql, true )
120
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
121
+ assert_equal utf16ify( " select * from foo" ), remainder
122
+ @driver.finalize( handle )
123
+ end
124
+
125
+ def test_complete
126
+ assert @driver.complete?( "select * from foo;" )
127
+ end
128
+
129
+ def test_complete_fail
130
+ assert !@driver.complete?( "select * from foo" )
131
+ end
132
+
133
+ def test_complete16
134
+ assert @driver.complete?( utf16ify("select * from foo;"), true )
135
+ end
136
+
137
+ def create_foo
138
+ result, @db = @driver.open( @dbname )
139
+ sql = "create table foo ( a, b )"
140
+ result, handle, = @driver.prepare( @db, sql )
141
+ @driver.step( handle )
142
+ @driver.finalize( handle )
143
+ end
144
+
145
+ def populate_foo
146
+ create_foo
147
+ sql = "insert into foo values ( 100, 200 )"
148
+ result, handle, = @driver.prepare( @db, sql )
149
+ @driver.step( handle )
150
+ @driver.finalize( handle )
151
+ end
152
+
153
+ def test_step
154
+ populate_foo
155
+ sql = "select * from foo"
156
+ result, handle, = @driver.prepare( @db, sql )
157
+ result = @driver.step( handle )
158
+ assert_equal SQLite3::Constants::ErrorCode::ROW, result
159
+ result = @driver.step( handle )
160
+ assert_equal SQLite3::Constants::ErrorCode::DONE, result
161
+ @driver.finalize( handle )
162
+ end
163
+
164
+ def test_step_fail
165
+ populate_foo
166
+ sql = "select * from"
167
+ result, handle, = @driver.prepare( @db, sql )
168
+ result = @driver.step( handle )
169
+ assert_equal SQLite3::Constants::ErrorCode::MISUSE, result
170
+ @driver.finalize( handle )
171
+ end
172
+
173
+ def test_bind_blob
174
+ create_foo
175
+ sql = "insert into foo (b) values (?)"
176
+ result, handle, = @driver.prepare( @db, sql )
177
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
178
+ result = @driver.bind_blob( handle, 1, "a\0b\1c\2d\0e" )
179
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
180
+ result = @driver.step( handle )
181
+ assert_equal SQLite3::Constants::ErrorCode::DONE, result
182
+ result = @driver.finalize( handle )
183
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
184
+ sql = "select b from foo"
185
+ result, handle, = @driver.prepare( @db, sql )
186
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
187
+ result = @driver.step( handle )
188
+ assert_equal SQLite3::Constants::ErrorCode::ROW, result
189
+ assert_equal "a\0b\1c\2d\0e", @driver.column_blob( handle, 0 )
190
+ result = @driver.finalize( handle )
191
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
192
+ end
193
+
194
+ def test_bind_double
195
+ create_foo
196
+ sql = "insert into foo (b) values (?)"
197
+ result, handle, = @driver.prepare( @db, sql )
198
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
199
+ result = @driver.bind_double( handle, 1, 3.14 )
200
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
201
+ result = @driver.step( handle )
202
+ assert_equal SQLite3::Constants::ErrorCode::DONE, result
203
+ result = @driver.finalize( handle )
204
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
205
+ sql = "select b from foo"
206
+ result, handle, = @driver.prepare( @db, sql )
207
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
208
+ result = @driver.step( handle )
209
+ assert_equal SQLite3::Constants::ErrorCode::ROW, result
210
+ assert_equal 3.14, @driver.column_double( handle, 0 )
211
+ result = @driver.finalize( handle )
212
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
213
+ end
214
+
215
+ def test_bind_int
216
+ create_foo
217
+ sql = "insert into foo (b) values (?)"
218
+ result, handle, = @driver.prepare( @db, sql )
219
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
220
+ result = @driver.bind_int( handle, 1, 14 )
221
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
222
+ result = @driver.step( handle )
223
+ assert_equal SQLite3::Constants::ErrorCode::DONE, result
224
+ result = @driver.finalize( handle )
225
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
226
+ sql = "select b from foo"
227
+ result, handle, = @driver.prepare( @db, sql )
228
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
229
+ result = @driver.step( handle )
230
+ assert_equal SQLite3::Constants::ErrorCode::ROW, result
231
+ assert_equal 14, @driver.column_int( handle, 0 )
232
+ result = @driver.finalize( handle )
233
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
234
+ end
235
+
236
+ def test_bind_null
237
+ create_foo
238
+ sql = "insert into foo (b) values (?)"
239
+ result, handle, = @driver.prepare( @db, sql )
240
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
241
+ result = @driver.bind_null( handle, 1 )
242
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
243
+ result = @driver.step( handle )
244
+ assert_equal SQLite3::Constants::ErrorCode::DONE, result
245
+ result = @driver.finalize( handle )
246
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
247
+ sql = "select b from foo"
248
+ result, handle, = @driver.prepare( @db, sql )
249
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
250
+ result = @driver.step( handle )
251
+ assert_equal SQLite3::Constants::ErrorCode::ROW, result
252
+ assert_equal SQLite3::Constants::ColumnType::NULL,
253
+ @driver.column_type( handle, 0 )
254
+ result = @driver.finalize( handle )
255
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
256
+ end
257
+
258
+ def test_bind_text
259
+ create_foo
260
+ sql = "insert into foo (b) values (?)"
261
+ result, handle, = @driver.prepare( @db, sql )
262
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
263
+ result = @driver.bind_text( handle, 1, "hello, world" )
264
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
265
+ result = @driver.step( handle )
266
+ assert_equal SQLite3::Constants::ErrorCode::DONE, result
267
+ result = @driver.finalize( handle )
268
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
269
+ sql = "select b from foo"
270
+ result, handle, = @driver.prepare( @db, sql )
271
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
272
+ result = @driver.step( handle )
273
+ assert_equal SQLite3::Constants::ErrorCode::ROW, result
274
+ assert_equal "hello, world", @driver.column_text( handle, 0 )
275
+ result = @driver.finalize( handle )
276
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
277
+ end
278
+
279
+ def test_bind_text16
280
+ create_foo
281
+ sql = "insert into foo (b) values (?)"
282
+ result, handle, = @driver.prepare( @db, sql )
283
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
284
+ result = @driver.bind_text( handle, 1, utf16ify("hello, world"), true )
285
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
286
+ result = @driver.step( handle )
287
+ assert_equal SQLite3::Constants::ErrorCode::DONE, result
288
+ result = @driver.finalize( handle )
289
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
290
+ sql = "select b from foo"
291
+ result, handle, = @driver.prepare( @db, sql )
292
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
293
+ result = @driver.step( handle )
294
+ assert_equal SQLite3::Constants::ErrorCode::ROW, result
295
+ assert_equal "hello, world", @driver.column_text( handle, 0 )
296
+ result = @driver.finalize( handle )
297
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
298
+ end
299
+
300
+ def test_bind_parameter_index
301
+ create_foo
302
+ sql = "insert into foo (b) values (:hello)"
303
+ result, handle, = @driver.prepare( @db, sql )
304
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
305
+ result = @driver.bind_parameter_index( handle, ":hello" )
306
+ assert_equal 1, result
307
+ result = @driver.bind_parameter_index( handle, ":foo" )
308
+ assert_equal 0, result
309
+ @driver.finalize( handle )
310
+ end
311
+
312
+ def test_bind_parameter_name
313
+ create_foo
314
+ sql = "insert into foo (a,b) values (?,:foo)"
315
+ result, handle, = @driver.prepare( @db, sql )
316
+ assert_equal SQLite3::Constants::ErrorCode::OK, result
317
+ assert_nil nil, @driver.bind_parameter_name(handle,1)
318
+ assert_equal ":foo", @driver.bind_parameter_name(handle,2)
319
+ @driver.finalize( handle )
320
+ end
321
+
322
+ end