sqlite3-ruby 1.1.0 → 1.2.0

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,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
@@ -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, nil, "could not open database" )
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 &block
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 Exception
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
- API.sqlite3_busy_handler( db,
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
- API.sqlite3_set_authorizer( db,
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
- API.sqlite3_trace( db,
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 )
@@ -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 ( EXCEPTIONS[result] || SQLite3::Exception ), msg
94
+ raise(( EXCEPTIONS[result] || SQLite3::Exception ), msg)
95
95
  end
96
96
  end
97
97
  module_function :check
@@ -81,6 +81,7 @@ module SQLite3
81
81
  # can be rewound and reiterated.
82
82
  def reset( *bind_params )
83
83
  @stmt.must_be_open!
84
+ @stmt.reset!(false)
84
85
  @driver.reset( @stmt.handle )
85
86
  @stmt.bind_params( *bind_params )
86
87
  @eof = false
@@ -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
- index = @driver.bind_parameter_index(
133
- @handle, param.to_s )
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
- @driver.reset( @handle ) if @results
160
+ reset! if active?
156
161
 
157
- bind_params *bind_vars unless bind_vars.empty?
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.
@@ -81,6 +81,7 @@ module SQLite3
81
81
  # A convenience method for working with type names. This returns the "base"
82
82
  # type name, without any parenthetical data.
83
83
  def type_name( type )
84
+ return "" if type.nil?
84
85
  type = $1 if type =~ /^(.*?)\(/
85
86
  type.upcase
86
87
  end
@@ -35,7 +35,7 @@ module SQLite3
35
35
  module Version
36
36
 
37
37
  MAJOR = 1
38
- MINOR = 1
38
+ MINOR = 2
39
39
  TINY = 0
40
40
 
41
41
  STRING = [ MAJOR, MINOR, TINY ].join( "." )
@@ -30,293 +30,295 @@
30
30
  # =============================================================================
31
31
  #++
32
32
 
33
- $:.unshift "../../../lib"
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
- def utf16ify( str )
42
- chars = str.split(//)
43
- chars.zip(["\0"] * chars.length).flatten.join
44
- end
42
+ def utf16ify( str )
43
+ chars = str.split(//)
44
+ chars.zip(["\0"] * chars.length).flatten.join
45
+ end
45
46
 
46
- def setup
47
- @driver = SQLite3::Driver::DL::Driver.new
48
- @dbname = "test.db"
49
- @db = nil
50
- end
47
+ def setup
48
+ @driver = SQLite3::Driver::DL::Driver.new
49
+ @dbname = "test.db"
50
+ @db = nil
51
+ end
51
52
 
52
- def teardown
53
- @driver.close( @db ) rescue nil
54
- File.delete @dbname rescue nil
55
- end
53
+ def teardown
54
+ @driver.close( @db ) rescue nil
55
+ File.delete @dbname rescue nil
56
+ end
56
57
 
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
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
- 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
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
- def test_errmsg
71
- result, @db = @driver.open( @dbname )
72
- msg = @driver.errmsg( @db )
73
- assert_equal msg, "not an error"
74
- end
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- def test_complete
126
- assert @driver.complete?( "select * from foo;" )
127
- end
126
+ def test_complete
127
+ assert @driver.complete?( "select * from foo;" )
128
+ end
128
129
 
129
- def test_complete_fail
130
- assert !@driver.complete?( "select * from foo" )
131
- end
130
+ def test_complete_fail
131
+ assert !@driver.complete?( "select * from foo" )
132
+ end
132
133
 
133
- def test_complete16
134
- assert @driver.complete?( utf16ify("select * from foo;"), true )
135
- end
134
+ def test_complete16
135
+ assert @driver.complete?( utf16ify("select * from foo;"), true )
136
+ end
136
137
 
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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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