sqlite3-ruby 1.1.0-mswin32 → 1.2.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.
- data/README +24 -5
- data/doc/faq/faq.html +58 -32
- data/ext/sqlite3_api/Makefile +143 -0
- data/ext/sqlite3_api/extconf.rb +7 -2
- data/ext/sqlite3_api/sqlite3_api.i +12 -0
- data/ext/sqlite3_api/sqlite3_api_wrap.c +3095 -0
- data/ext/sqlite3_api/win32/build.bat +7 -0
- data/lib/sqlite3/database.rb +4 -3
- data/lib/sqlite3/driver/dl/driver.rb +4 -0
- data/lib/sqlite3/driver/native/driver.rb +35 -10
- data/lib/sqlite3/errors.rb +1 -1
- data/lib/sqlite3/resultset.rb +1 -0
- data/lib/sqlite3/statement.rb +22 -4
- data/lib/sqlite3/translator.rb +1 -0
- data/lib/sqlite3/version.rb +1 -1
- data/lib/sqlite3_api.so +0 -0
- data/test/driver/dl/tc_driver.rb +262 -260
- data/test/mocks.rb +3 -0
- data/test/tc_integration.rb +64 -16
- metadata +62 -54
- data/ext/sqlite3_api/post-clean.rb +0 -3
- data/ext/sqlite3_api/post-distclean.rb +0 -4
@@ -0,0 +1,7 @@
|
|
1
|
+
REM This is not guaranteed to work, ever. It's just a little helper
|
2
|
+
REM script that I threw together to help me build the win32 version of
|
3
|
+
REM the library. If someone with more win32-fu than I wants to make
|
4
|
+
REM something more robust, please feel free! I'd love to include it.
|
5
|
+
REM -- Jamis Buck
|
6
|
+
|
7
|
+
cl /LD /Ie:\WinSDK\Include /Ic:\ruby\lib\ruby\1.8\i386-mswin32 /Ic:\ruby\sqlite3\src /Ic:\ruby\src\ruby-1.8.4_2006-04-14 sqlite3_api_wrap.c /link /LIBPATH:c:\ruby\sqlite3 /LIBPATH:e:\WinSDK\Lib /LIBPATH:c:\ruby\lib sqlite3.lib msvcrt-ruby18.lib
|
data/lib/sqlite3/database.rb
CHANGED
@@ -109,12 +109,13 @@ module SQLite3
|
|
109
109
|
@statement_factory = options[:statement_factory] || Statement
|
110
110
|
|
111
111
|
result, @handle = @driver.open( file_name, utf16 )
|
112
|
-
Error.check( result,
|
112
|
+
Error.check( result, self, "could not open database" )
|
113
113
|
|
114
114
|
@closed = false
|
115
115
|
@results_as_hash = options.fetch(:results_as_hash,false)
|
116
116
|
@type_translation = options.fetch(:type_translation,false)
|
117
117
|
@translator = nil
|
118
|
+
@transaction_active = false
|
118
119
|
end
|
119
120
|
|
120
121
|
# Return +true+ if the string is a valid (ie, parsable) SQL statement, and
|
@@ -436,7 +437,7 @@ module SQLite3
|
|
436
437
|
# begin
|
437
438
|
if block
|
438
439
|
proxy = AggregateDefinitionProxy.new
|
439
|
-
proxy.instance_eval
|
440
|
+
proxy.instance_eval(&block)
|
440
441
|
step ||= proxy.step_callback
|
441
442
|
finalize ||= proxy.finalize_callback
|
442
443
|
end
|
@@ -591,7 +592,7 @@ module SQLite3
|
|
591
592
|
abort = false
|
592
593
|
begin
|
593
594
|
yield self
|
594
|
-
rescue
|
595
|
+
rescue ::Object
|
595
596
|
abort = true
|
596
597
|
raise
|
597
598
|
ensure
|
@@ -32,6 +32,10 @@
|
|
32
32
|
|
33
33
|
require 'sqlite3/driver/dl/api'
|
34
34
|
|
35
|
+
warn "The DL driver for sqlite3-ruby is deprecated and will be removed"
|
36
|
+
warn "in a future release. Please update your installation to use the"
|
37
|
+
warn "Native driver."
|
38
|
+
|
35
39
|
module Kernel
|
36
40
|
# Allows arbitrary objects to be passed as a pointer to functions.
|
37
41
|
# (Probably not very GC safe, but by encapsulating it like this we
|
@@ -38,6 +38,9 @@ module SQLite3 ; module Driver ; module Native
|
|
38
38
|
|
39
39
|
def initialize
|
40
40
|
@callback_data = Hash.new
|
41
|
+
@authorizer = Hash.new
|
42
|
+
@busy_handler = Hash.new
|
43
|
+
@trace = Hash.new
|
41
44
|
end
|
42
45
|
|
43
46
|
def complete?( sql, utf16=false )
|
@@ -49,10 +52,18 @@ module SQLite3 ; module Driver ; module Native
|
|
49
52
|
cb = API::CallbackData.new
|
50
53
|
cb.proc = block
|
51
54
|
cb.data = data
|
55
|
+
result = API.sqlite3_busy_handler( db, API::Sqlite3_ruby_busy_handler, cb )
|
56
|
+
# Reference the Callback object so that
|
57
|
+
# it is not deleted by the GC
|
58
|
+
@busy_handler[db] = cb
|
59
|
+
else
|
60
|
+
# Unreference the callback *after* having removed it
|
61
|
+
# from sqlite
|
62
|
+
result = API.sqlite3_busy_handler( db, nil, nil )
|
63
|
+
@busy_handler.delete(db)
|
52
64
|
end
|
53
65
|
|
54
|
-
|
55
|
-
block ? API::Sqlite3_ruby_busy_handler : nil, cb )
|
66
|
+
result
|
56
67
|
end
|
57
68
|
|
58
69
|
def set_authorizer( db, data=nil, &block )
|
@@ -60,10 +71,14 @@ module SQLite3 ; module Driver ; module Native
|
|
60
71
|
cb = API::CallbackData.new
|
61
72
|
cb.proc = block
|
62
73
|
cb.data = data
|
74
|
+
result = API.sqlite3_set_authorizer( db, API::Sqlite3_ruby_authorizer, cb )
|
75
|
+
@authorizer[db] = cb # see comments in busy_handler
|
76
|
+
else
|
77
|
+
result = API.sqlite3_set_authorizer( db, nil, nil )
|
78
|
+
@authorizer.delete(db) # see comments in busy_handler
|
63
79
|
end
|
64
80
|
|
65
|
-
|
66
|
-
block ? API::Sqlite3_ruby_authorizer : nil, cb )
|
81
|
+
result
|
67
82
|
end
|
68
83
|
|
69
84
|
def trace( db, data=nil, &block )
|
@@ -71,10 +86,14 @@ module SQLite3 ; module Driver ; module Native
|
|
71
86
|
cb = API::CallbackData.new
|
72
87
|
cb.proc = block
|
73
88
|
cb.data = data
|
89
|
+
result = API.sqlite3_trace( db, API::Sqlite3_ruby_trace, cb )
|
90
|
+
@trace[db] = cb # see comments in busy_handler
|
91
|
+
else
|
92
|
+
result = API.sqlite3_trace( db, nil, nil )
|
93
|
+
@trace.delete(db) # see comments in busy_handler
|
74
94
|
end
|
75
95
|
|
76
|
-
|
77
|
-
block ? API::Sqlite3_ruby_trace : nil, cb )
|
96
|
+
result
|
78
97
|
end
|
79
98
|
|
80
99
|
def open( filename, utf16=false )
|
@@ -116,9 +135,6 @@ module SQLite3 ; module Driver ; module Native
|
|
116
135
|
cb = API::CallbackData.new
|
117
136
|
cb.proc = cb.proc2 = nil
|
118
137
|
cb.data = cookie
|
119
|
-
@callback_data[ name ] = cb
|
120
|
-
else
|
121
|
-
@callback_data.delete( name )
|
122
138
|
end
|
123
139
|
|
124
140
|
if func
|
@@ -135,7 +151,16 @@ module SQLite3 ; module Driver ; module Native
|
|
135
151
|
final = API::Sqlite3_ruby_function_final
|
136
152
|
end
|
137
153
|
|
138
|
-
API.sqlite3_create_function( db, name, args, text, cb, func, step, final )
|
154
|
+
result = API.sqlite3_create_function( db, name, args, text, cb, func, step, final )
|
155
|
+
|
156
|
+
# see comments in busy_handler
|
157
|
+
if cb
|
158
|
+
@callback_data[ name ] = cb
|
159
|
+
else
|
160
|
+
@callback_data.delete( name )
|
161
|
+
end
|
162
|
+
|
163
|
+
return result
|
139
164
|
end
|
140
165
|
|
141
166
|
def value_text( value, utf16=false )
|
data/lib/sqlite3/errors.rb
CHANGED
@@ -91,7 +91,7 @@ module SQLite3
|
|
91
91
|
def check( result, db=nil, msg=nil )
|
92
92
|
unless result == Constants::ErrorCode::OK
|
93
93
|
msg = ( msg ? msg + ": " : "" ) + db.errmsg if db
|
94
|
-
raise
|
94
|
+
raise(( EXCEPTIONS[result] || SQLite3::Exception ), msg)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
module_function :check
|
data/lib/sqlite3/resultset.rb
CHANGED
data/lib/sqlite3/statement.rb
CHANGED
@@ -66,6 +66,7 @@ module SQLite3
|
|
66
66
|
@db = db
|
67
67
|
@driver = @db.driver
|
68
68
|
@closed = false
|
69
|
+
@results = @columns = nil
|
69
70
|
result, @handle, @remainder = @driver.prepare( @db.handle, sql )
|
70
71
|
Error.check( result, @db )
|
71
72
|
end
|
@@ -115,8 +116,11 @@ module SQLite3
|
|
115
116
|
# See also #bind_params.
|
116
117
|
def bind_param( param, value )
|
117
118
|
must_be_open!
|
119
|
+
reset! if active?
|
118
120
|
if Fixnum === param
|
119
121
|
case value
|
122
|
+
when Bignum then
|
123
|
+
@driver.bind_int64( @handle, param, value )
|
120
124
|
when Integer then
|
121
125
|
@driver.bind_int( @handle, param, value )
|
122
126
|
when Numeric then
|
@@ -129,8 +133,9 @@ module SQLite3
|
|
129
133
|
@driver.bind_text( @handle, param, value )
|
130
134
|
end
|
131
135
|
else
|
132
|
-
|
133
|
-
|
136
|
+
param = param.to_s
|
137
|
+
param = ":#{param}" unless param[0] == ?:
|
138
|
+
index = @driver.bind_parameter_index( @handle, param )
|
134
139
|
raise Exception, "no such bind parameter '#{param}'" if index == 0
|
135
140
|
bind_param index, value
|
136
141
|
end
|
@@ -152,9 +157,9 @@ module SQLite3
|
|
152
157
|
# See also #bind_params, #execute!.
|
153
158
|
def execute( *bind_vars )
|
154
159
|
must_be_open!
|
155
|
-
|
160
|
+
reset! if active?
|
156
161
|
|
157
|
-
bind_params
|
162
|
+
bind_params(*bind_vars) unless bind_vars.empty?
|
158
163
|
@results = ResultSet.new( @db, self )
|
159
164
|
|
160
165
|
if block_given?
|
@@ -191,6 +196,19 @@ module SQLite3
|
|
191
196
|
rows
|
192
197
|
end
|
193
198
|
|
199
|
+
# Resets the statement. This is typically done internally, though it might
|
200
|
+
# occassionally be necessary to manually reset the statement.
|
201
|
+
def reset!(clear_result=true)
|
202
|
+
@driver.reset(@handle)
|
203
|
+
@results = nil if clear_result
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns true if the statement is currently active, meaning it has an
|
207
|
+
# open result set.
|
208
|
+
def active?
|
209
|
+
not @results.nil?
|
210
|
+
end
|
211
|
+
|
194
212
|
# Return an array of the column names for this statement. Note that this
|
195
213
|
# may execute the statement in order to obtain the metadata; this makes it
|
196
214
|
# a (potentially) expensive operation.
|
data/lib/sqlite3/translator.rb
CHANGED
data/lib/sqlite3/version.rb
CHANGED
data/lib/sqlite3_api.so
CHANGED
Binary file
|
data/test/driver/dl/tc_driver.rb
CHANGED
@@ -30,293 +30,295 @@
|
|
30
30
|
# =============================================================================
|
31
31
|
#++
|
32
32
|
|
33
|
-
|
33
|
+
if (ENV["SQLITE3_DRIVERS"] || "Native").split(/,/).include?("DL")
|
34
|
+
$:.unshift "../../../lib"
|
34
35
|
|
35
|
-
require 'sqlite3/constants'
|
36
|
-
require 'sqlite3/driver/dl/driver'
|
37
|
-
require 'test/unit'
|
36
|
+
require 'sqlite3/constants'
|
37
|
+
require 'sqlite3/driver/dl/driver'
|
38
|
+
require 'test/unit'
|
38
39
|
|
39
|
-
class TC_DL_Driver < Test::Unit::TestCase
|
40
|
+
class TC_DL_Driver < Test::Unit::TestCase
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
def utf16ify( str )
|
43
|
+
chars = str.split(//)
|
44
|
+
chars.zip(["\0"] * chars.length).flatten.join
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
def setup
|
48
|
+
@driver = SQLite3::Driver::DL::Driver.new
|
49
|
+
@dbname = "test.db"
|
50
|
+
@db = nil
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
def teardown
|
54
|
+
@driver.close( @db ) rescue nil
|
55
|
+
File.delete @dbname rescue nil
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
def test_open
|
59
|
+
result, @db = @driver.open( @dbname )
|
60
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
61
|
+
assert File.exist?( @dbname )
|
62
|
+
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
def test_open_utf16
|
65
|
+
name = utf16ify( @dbname )
|
66
|
+
result, @db = @driver.open( name, true )
|
67
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
68
|
+
assert File.exist?( @dbname )
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
def test_errmsg
|
72
|
+
result, @db = @driver.open( @dbname )
|
73
|
+
msg = @driver.errmsg( @db )
|
74
|
+
assert_equal msg, "not an error"
|
75
|
+
end
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
def test_errmsg16
|
78
|
+
result, @db = @driver.open( @dbname )
|
79
|
+
msg = @driver.errmsg( @db, true )
|
80
|
+
assert_equal msg, utf16ify( "not an error" )
|
81
|
+
end
|
81
82
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
def test_prepare
|
84
|
+
result, @db = @driver.open( @dbname )
|
85
|
+
sql = "create table foo ( a, b )"
|
86
|
+
result, handle, remainder = @driver.prepare( @db, sql )
|
87
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
88
|
+
assert_equal "", remainder
|
89
|
+
@driver.finalize( handle )
|
90
|
+
end
|
90
91
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
92
|
+
def test_prepare_error
|
93
|
+
result, @db = @driver.open( @dbname )
|
94
|
+
sql = "create tble foo ( a, b )"
|
95
|
+
result, handle, remainder = @driver.prepare( @db, sql )
|
96
|
+
assert_equal SQLite3::Constants::ErrorCode::ERROR, result
|
97
|
+
end
|
97
98
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
99
|
+
def test_prepare_remainder
|
100
|
+
result, @db = @driver.open( @dbname )
|
101
|
+
sql = "create table foo ( a, b ); select * from foo"
|
102
|
+
result, handle, remainder = @driver.prepare( @db, sql )
|
103
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
104
|
+
assert_equal " select * from foo", remainder
|
105
|
+
@driver.finalize( handle )
|
106
|
+
end
|
106
107
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
108
|
+
def test_prepare16
|
109
|
+
result, @db = @driver.open( @dbname )
|
110
|
+
sql = utf16ify( "create table foo ( a, b )" )
|
111
|
+
result, handle, remainder = @driver.prepare( @db, sql, true )
|
112
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
113
|
+
assert_equal "", remainder
|
114
|
+
@driver.finalize( handle )
|
115
|
+
end
|
115
116
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
117
|
+
def test_prepare16_remainder
|
118
|
+
result, @db = @driver.open( @dbname )
|
119
|
+
sql = utf16ify( "create table foo ( a, b ); select * from foo" )
|
120
|
+
result, handle, remainder = @driver.prepare( @db, sql, true )
|
121
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
122
|
+
assert_equal utf16ify( " select * from foo" ), remainder
|
123
|
+
@driver.finalize( handle )
|
124
|
+
end
|
124
125
|
|
125
|
-
|
126
|
-
|
127
|
-
|
126
|
+
def test_complete
|
127
|
+
assert @driver.complete?( "select * from foo;" )
|
128
|
+
end
|
128
129
|
|
129
|
-
|
130
|
-
|
131
|
-
|
130
|
+
def test_complete_fail
|
131
|
+
assert !@driver.complete?( "select * from foo" )
|
132
|
+
end
|
132
133
|
|
133
|
-
|
134
|
-
|
135
|
-
|
134
|
+
def test_complete16
|
135
|
+
assert @driver.complete?( utf16ify("select * from foo;"), true )
|
136
|
+
end
|
136
137
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
138
|
+
def create_foo
|
139
|
+
result, @db = @driver.open( @dbname )
|
140
|
+
sql = "create table foo ( a, b )"
|
141
|
+
result, handle, = @driver.prepare( @db, sql )
|
142
|
+
@driver.step( handle )
|
143
|
+
@driver.finalize( handle )
|
144
|
+
end
|
144
145
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
146
|
+
def populate_foo
|
147
|
+
create_foo
|
148
|
+
sql = "insert into foo values ( 100, 200 )"
|
149
|
+
result, handle, = @driver.prepare( @db, sql )
|
150
|
+
@driver.step( handle )
|
151
|
+
@driver.finalize( handle )
|
152
|
+
end
|
152
153
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
154
|
+
def test_step
|
155
|
+
populate_foo
|
156
|
+
sql = "select * from foo"
|
157
|
+
result, handle, = @driver.prepare( @db, sql )
|
158
|
+
result = @driver.step( handle )
|
159
|
+
assert_equal SQLite3::Constants::ErrorCode::ROW, result
|
160
|
+
result = @driver.step( handle )
|
161
|
+
assert_equal SQLite3::Constants::ErrorCode::DONE, result
|
162
|
+
@driver.finalize( handle )
|
163
|
+
end
|
163
164
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
165
|
+
def test_step_fail
|
166
|
+
populate_foo
|
167
|
+
sql = "select * from"
|
168
|
+
result, handle, = @driver.prepare( @db, sql )
|
169
|
+
result = @driver.step( handle )
|
170
|
+
assert_equal SQLite3::Constants::ErrorCode::MISUSE, result
|
171
|
+
@driver.finalize( handle )
|
172
|
+
end
|
172
173
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
174
|
+
def test_bind_blob
|
175
|
+
create_foo
|
176
|
+
sql = "insert into foo (b) values (?)"
|
177
|
+
result, handle, = @driver.prepare( @db, sql )
|
178
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
179
|
+
result = @driver.bind_blob( handle, 1, "a\0b\1c\2d\0e" )
|
180
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
181
|
+
result = @driver.step( handle )
|
182
|
+
assert_equal SQLite3::Constants::ErrorCode::DONE, result
|
183
|
+
result = @driver.finalize( handle )
|
184
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
185
|
+
sql = "select b from foo"
|
186
|
+
result, handle, = @driver.prepare( @db, sql )
|
187
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
188
|
+
result = @driver.step( handle )
|
189
|
+
assert_equal SQLite3::Constants::ErrorCode::ROW, result
|
190
|
+
assert_equal "a\0b\1c\2d\0e", @driver.column_blob( handle, 0 )
|
191
|
+
result = @driver.finalize( handle )
|
192
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
193
|
+
end
|
193
194
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
195
|
+
def test_bind_double
|
196
|
+
create_foo
|
197
|
+
sql = "insert into foo (b) values (?)"
|
198
|
+
result, handle, = @driver.prepare( @db, sql )
|
199
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
200
|
+
result = @driver.bind_double( handle, 1, 3.14 )
|
201
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
202
|
+
result = @driver.step( handle )
|
203
|
+
assert_equal SQLite3::Constants::ErrorCode::DONE, result
|
204
|
+
result = @driver.finalize( handle )
|
205
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
206
|
+
sql = "select b from foo"
|
207
|
+
result, handle, = @driver.prepare( @db, sql )
|
208
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
209
|
+
result = @driver.step( handle )
|
210
|
+
assert_equal SQLite3::Constants::ErrorCode::ROW, result
|
211
|
+
assert_equal 3.14, @driver.column_double( handle, 0 )
|
212
|
+
result = @driver.finalize( handle )
|
213
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
214
|
+
end
|
214
215
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
216
|
+
def test_bind_int
|
217
|
+
create_foo
|
218
|
+
sql = "insert into foo (b) values (?)"
|
219
|
+
result, handle, = @driver.prepare( @db, sql )
|
220
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
221
|
+
result = @driver.bind_int( handle, 1, 14 )
|
222
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
223
|
+
result = @driver.step( handle )
|
224
|
+
assert_equal SQLite3::Constants::ErrorCode::DONE, result
|
225
|
+
result = @driver.finalize( handle )
|
226
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
227
|
+
sql = "select b from foo"
|
228
|
+
result, handle, = @driver.prepare( @db, sql )
|
229
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
230
|
+
result = @driver.step( handle )
|
231
|
+
assert_equal SQLite3::Constants::ErrorCode::ROW, result
|
232
|
+
assert_equal 14, @driver.column_int( handle, 0 )
|
233
|
+
result = @driver.finalize( handle )
|
234
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
235
|
+
end
|
235
236
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
237
|
+
def test_bind_null
|
238
|
+
create_foo
|
239
|
+
sql = "insert into foo (b) values (?)"
|
240
|
+
result, handle, = @driver.prepare( @db, sql )
|
241
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
242
|
+
result = @driver.bind_null( handle, 1 )
|
243
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
244
|
+
result = @driver.step( handle )
|
245
|
+
assert_equal SQLite3::Constants::ErrorCode::DONE, result
|
246
|
+
result = @driver.finalize( handle )
|
247
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
248
|
+
sql = "select b from foo"
|
249
|
+
result, handle, = @driver.prepare( @db, sql )
|
250
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
251
|
+
result = @driver.step( handle )
|
252
|
+
assert_equal SQLite3::Constants::ErrorCode::ROW, result
|
253
|
+
assert_equal SQLite3::Constants::ColumnType::NULL,
|
254
|
+
@driver.column_type( handle, 0 )
|
255
|
+
result = @driver.finalize( handle )
|
256
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
257
|
+
end
|
257
258
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
259
|
+
def test_bind_text
|
260
|
+
create_foo
|
261
|
+
sql = "insert into foo (b) values (?)"
|
262
|
+
result, handle, = @driver.prepare( @db, sql )
|
263
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
264
|
+
result = @driver.bind_text( handle, 1, "hello, world" )
|
265
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
266
|
+
result = @driver.step( handle )
|
267
|
+
assert_equal SQLite3::Constants::ErrorCode::DONE, result
|
268
|
+
result = @driver.finalize( handle )
|
269
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
270
|
+
sql = "select b from foo"
|
271
|
+
result, handle, = @driver.prepare( @db, sql )
|
272
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
273
|
+
result = @driver.step( handle )
|
274
|
+
assert_equal SQLite3::Constants::ErrorCode::ROW, result
|
275
|
+
assert_equal "hello, world", @driver.column_text( handle, 0 )
|
276
|
+
result = @driver.finalize( handle )
|
277
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
278
|
+
end
|
278
279
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
280
|
+
def test_bind_text16
|
281
|
+
create_foo
|
282
|
+
sql = "insert into foo (b) values (?)"
|
283
|
+
result, handle, = @driver.prepare( @db, sql )
|
284
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
285
|
+
result = @driver.bind_text( handle, 1, utf16ify("hello, world"), true )
|
286
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
287
|
+
result = @driver.step( handle )
|
288
|
+
assert_equal SQLite3::Constants::ErrorCode::DONE, result
|
289
|
+
result = @driver.finalize( handle )
|
290
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
291
|
+
sql = "select b from foo"
|
292
|
+
result, handle, = @driver.prepare( @db, sql )
|
293
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
294
|
+
result = @driver.step( handle )
|
295
|
+
assert_equal SQLite3::Constants::ErrorCode::ROW, result
|
296
|
+
assert_equal "hello, world", @driver.column_text( handle, 0 )
|
297
|
+
result = @driver.finalize( handle )
|
298
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
299
|
+
end
|
299
300
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
301
|
+
def test_bind_parameter_index
|
302
|
+
create_foo
|
303
|
+
sql = "insert into foo (b) values (:hello)"
|
304
|
+
result, handle, = @driver.prepare( @db, sql )
|
305
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
306
|
+
result = @driver.bind_parameter_index( handle, ":hello" )
|
307
|
+
assert_equal 1, result
|
308
|
+
result = @driver.bind_parameter_index( handle, ":foo" )
|
309
|
+
assert_equal 0, result
|
310
|
+
@driver.finalize( handle )
|
311
|
+
end
|
311
312
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
313
|
+
def test_bind_parameter_name
|
314
|
+
create_foo
|
315
|
+
sql = "insert into foo (a,b) values (?,:foo)"
|
316
|
+
result, handle, = @driver.prepare( @db, sql )
|
317
|
+
assert_equal SQLite3::Constants::ErrorCode::OK, result
|
318
|
+
assert_nil nil, @driver.bind_parameter_name(handle,1)
|
319
|
+
assert_equal ":foo", @driver.bind_parameter_name(handle,2)
|
320
|
+
@driver.finalize( handle )
|
321
|
+
end
|
321
322
|
|
322
|
-
end
|
323
|
+
end
|
324
|
+
end
|