femto-sqlite3 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gemtest +0 -0
  2. data/API_CHANGES.rdoc +50 -0
  3. data/CHANGELOG.rdoc +245 -0
  4. data/ChangeLog.cvs +88 -0
  5. data/LICENSE +27 -0
  6. data/Manifest.txt +50 -0
  7. data/README.rdoc +99 -0
  8. data/Rakefile +10 -0
  9. data/ext/sqlite3/backup.c +168 -0
  10. data/ext/sqlite3/backup.h +15 -0
  11. data/ext/sqlite3/database.c +822 -0
  12. data/ext/sqlite3/database.h +15 -0
  13. data/ext/sqlite3/exception.c +94 -0
  14. data/ext/sqlite3/exception.h +8 -0
  15. data/ext/sqlite3/extconf.rb +51 -0
  16. data/ext/sqlite3/sqlite3.c +40 -0
  17. data/ext/sqlite3/sqlite3_ruby.h +53 -0
  18. data/ext/sqlite3/statement.c +438 -0
  19. data/ext/sqlite3/statement.h +16 -0
  20. data/faq/faq.rb +145 -0
  21. data/faq/faq.yml +426 -0
  22. data/lib/sqlite3.rb +10 -0
  23. data/lib/sqlite3/constants.rb +49 -0
  24. data/lib/sqlite3/database.rb +579 -0
  25. data/lib/sqlite3/errors.rb +44 -0
  26. data/lib/sqlite3/pragmas.rb +280 -0
  27. data/lib/sqlite3/resultset.rb +195 -0
  28. data/lib/sqlite3/statement.rb +144 -0
  29. data/lib/sqlite3/translator.rb +118 -0
  30. data/lib/sqlite3/value.rb +57 -0
  31. data/lib/sqlite3/version.rb +25 -0
  32. data/setup.rb +1333 -0
  33. data/tasks/faq.rake +9 -0
  34. data/tasks/gem.rake +32 -0
  35. data/tasks/native.rake +37 -0
  36. data/tasks/vendor_sqlite3.rake +48 -0
  37. data/test/helper.rb +14 -0
  38. data/test/test_backup.rb +33 -0
  39. data/test/test_collation.rb +82 -0
  40. data/test/test_database.rb +350 -0
  41. data/test/test_database_readonly.rb +29 -0
  42. data/test/test_deprecated.rb +44 -0
  43. data/test/test_encoding.rb +121 -0
  44. data/test/test_integration.rb +555 -0
  45. data/test/test_integration_open_close.rb +30 -0
  46. data/test/test_integration_pending.rb +115 -0
  47. data/test/test_integration_resultset.rb +159 -0
  48. data/test/test_integration_statement.rb +194 -0
  49. data/test/test_result_set.rb +37 -0
  50. data/test/test_sqlite3.rb +9 -0
  51. data/test/test_statement.rb +249 -0
  52. data/test/test_statement_execute.rb +35 -0
  53. metadata +200 -0
data/tasks/faq.rake ADDED
@@ -0,0 +1,9 @@
1
+ # Generate FAQ
2
+ desc "Generate the FAQ document"
3
+ task :faq => ['faq/faq.html']
4
+
5
+ file 'faq/faq.html' => ['faq/faq.rb', 'faq/faq.yml'] do
6
+ cd 'faq' do
7
+ ruby "faq.rb > faq.html"
8
+ end
9
+ end
data/tasks/gem.rake ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'hoe'
3
+ rescue LoadError
4
+ # try with rubygems?
5
+ require 'rubygems'
6
+ require 'hoe'
7
+ end
8
+
9
+ Hoe.plugin :debugging, :doofus, :git
10
+
11
+ HOE = Hoe.spec 'femto-sqlite3' do
12
+ developer 'Jamis Buck', 'jamis@37signals.com'
13
+ developer 'Luis Lavena', 'luislavena@gmail.com'
14
+ developer 'Aaron Patterson', 'aaron@tenderlovemaking.com'
15
+
16
+ self.readme_file = 'README.rdoc'
17
+ self.history_file = 'CHANGELOG.rdoc'
18
+ self.extra_rdoc_files = FileList['*.rdoc', 'ext/**/*.c']
19
+
20
+ spec_extras[:required_ruby_version] = Gem::Requirement.new('>= 1.8.7')
21
+ spec_extras[:required_rubygems_version] = '>= 1.3.5'
22
+ spec_extras[:extensions] = ["ext/sqlite3/extconf.rb"]
23
+
24
+ extra_dev_deps << ['rake-compiler', "~> 0.7.0"]
25
+ extra_dev_deps << ["mini_portile", "~> 0.2.2"]
26
+
27
+ clean_globs.push('**/test.db')
28
+ end
29
+
30
+ Hoe.add_include_dirs '.'
31
+
32
+ # vim: syntax=ruby
data/tasks/native.rake ADDED
@@ -0,0 +1,37 @@
1
+ # use rake-compiler for building the extension
2
+ require 'rake/extensiontask'
3
+
4
+ # NOTE: version used by cross compilation of Windows native extension
5
+ # It do not affect compilation under other operating systems
6
+ # The version indicated is the minimum DLL suggested for correct functionality
7
+ BINARY_VERSION = "3.7.13"
8
+ URL_VERSION = "3071300"
9
+
10
+ # build sqlite3_native C extension
11
+ Rake::ExtensionTask.new('sqlite3_native', HOE.spec) do |ext|
12
+ # where to locate the extension
13
+ ext.ext_dir = 'ext/sqlite3'
14
+
15
+ # where native extension will be copied (matches makefile)
16
+ ext.lib_dir = "lib/sqlite3"
17
+
18
+ # clean binary folders always
19
+ CLEAN.include("#{ext.lib_dir}/?.?")
20
+
21
+ # automatically add build options to avoid need of manual input
22
+ if RUBY_PLATFORM =~ /mswin|mingw/ then
23
+ # define target for extension (supporting fat binaries)
24
+ RUBY_VERSION =~ /(\d+\.\d+)/
25
+ ext.lib_dir = "lib/sqlite3/#{$1}"
26
+ ext.config_options << "--enable-local"
27
+ else
28
+ ext.cross_compile = true
29
+ ext.cross_platform = ['i386-mswin32-60', 'i386-mingw32']
30
+ ext.cross_config_options << "--enable-local"
31
+ end
32
+ end
33
+
34
+ # ensure things are compiled prior testing
35
+ task :test => [:compile]
36
+
37
+ # vim: syntax=ruby
@@ -0,0 +1,48 @@
1
+ require "rake/clean"
2
+ require "rake/extensioncompiler"
3
+ require "mini_portile"
4
+
5
+ $recipes = {}
6
+
7
+ $recipes[:sqlite3] = MiniPortile.new "sqlite3", BINARY_VERSION
8
+ $recipes[:sqlite3].files << "http://sqlite.org/sqlite-autoconf-#{URL_VERSION}.tar.gz"
9
+
10
+ namespace :ports do
11
+ directory "ports"
12
+
13
+ desc "Install port sqlite3 #{$recipes[:sqlite3].version}"
14
+ task :sqlite3 => ["ports"] do |t|
15
+ recipe = $recipes[:sqlite3]
16
+ checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
17
+
18
+ unless File.exist?(checkpoint)
19
+ cflags = "-O2 -DSQLITE_ENABLE_COLUMN_METADATA"
20
+ cflags << " -fPIC" if recipe.host.include?("x86_64")
21
+ recipe.configure_options << "CFLAGS='#{cflags}'"
22
+ recipe.cook
23
+ touch checkpoint
24
+ end
25
+
26
+ recipe.activate
27
+ end
28
+ end
29
+
30
+ if RUBY_PLATFORM =~ /mingw/
31
+ Rake::Task['compile'].prerequisites.unshift "ports:sqlite3"
32
+ end
33
+
34
+ if ENV["USE_MINI_PORTILE"] == "true"
35
+ Rake::Task["compile"].prerequisites.unshift "ports:sqlite3"
36
+ end
37
+
38
+ task :cross do
39
+ host = ENV.fetch("HOST", Rake::ExtensionCompiler.mingw_host)
40
+ $recipes.each do |_, recipe|
41
+ recipe.host = host
42
+ end
43
+
44
+ # hook compile task with dependencies
45
+ Rake::Task["compile"].prerequisites.unshift "ports:sqlite3"
46
+ end
47
+
48
+ CLOBBER.include("ports")
data/test/helper.rb ADDED
@@ -0,0 +1,14 @@
1
+ require 'sqlite3'
2
+ require 'test/unit'
3
+
4
+ unless RUBY_VERSION >= "1.9"
5
+ require 'iconv'
6
+ end
7
+
8
+ module SQLite3
9
+ class TestCase < Test::Unit::TestCase
10
+ unless RUBY_VERSION >= '1.9'
11
+ undef :default_test
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestBackup < SQLite3::TestCase
5
+ def setup
6
+ @sdb = SQLite3::Database.new(':memory:')
7
+ @ddb = SQLite3::Database.new(':memory:')
8
+ @sdb.execute('CREATE TABLE foo (idx, val);');
9
+ @data = ('A'..'Z').map{|x|x * 40}
10
+ @data.each_with_index do |v, i|
11
+ @sdb.execute('INSERT INTO foo (idx, val) VALUES (?, ?);', [i, v])
12
+ end
13
+ end
14
+
15
+ def test_backup_step
16
+ b = SQLite3::Backup.new(@ddb, 'main', @sdb, 'main')
17
+ while b.step(1) == SQLite3::Constants::ErrorCode::OK
18
+ assert_not_equal(0, b.remaining)
19
+ end
20
+ assert_equal(0, b.remaining)
21
+ b.finish
22
+ assert_equal(@data.length, @ddb.execute('SELECT * FROM foo;').length)
23
+ end
24
+
25
+ def test_backup_all
26
+ b = SQLite3::Backup.new(@ddb, 'main', @sdb, 'main')
27
+ assert_equal(SQLite3::Constants::ErrorCode::DONE, b.step(-1))
28
+ assert_equal(0, b.remaining)
29
+ b.finish
30
+ assert_equal(@data.length, @ddb.execute('SELECT * FROM foo;').length)
31
+ end
32
+ end if defined?(SQLite3::Backup)
33
+ end
@@ -0,0 +1,82 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'helper'
4
+
5
+ module SQLite3
6
+ class TestCollation < SQLite3::TestCase
7
+ class Comparator
8
+ attr_reader :calls
9
+ def initialize
10
+ @calls = []
11
+ end
12
+
13
+ def compare left, right
14
+ @calls << [left, right]
15
+ left <=> right
16
+ end
17
+ end
18
+
19
+ def setup
20
+ @db = SQLite3::Database.new(':memory:')
21
+ @create = "create table ex(id int, data string)"
22
+ @db.execute(@create);
23
+ [ [1, 'hello'], [2, 'world'] ].each do |vals|
24
+ @db.execute('insert into ex (id, data) VALUES (?, ?)', vals)
25
+ end
26
+ end
27
+
28
+ def test_custom_collation
29
+ comparator = Comparator.new
30
+
31
+ @db.collation 'foo', comparator
32
+
33
+ assert_equal comparator, @db.collations['foo']
34
+ @db.execute('select data from ex order by 1 collate foo')
35
+ assert_equal 1, comparator.calls.length
36
+ end
37
+
38
+ def test_remove_collation
39
+ comparator = Comparator.new
40
+
41
+ @db.collation 'foo', comparator
42
+ @db.collation 'foo', nil
43
+
44
+ assert_nil @db.collations['foo']
45
+ assert_raises(SQLite3::SQLException) do
46
+ @db.execute('select data from ex order by 1 collate foo')
47
+ end
48
+ end
49
+
50
+ if RUBY_VERSION >= '1.9.1'
51
+ def test_encoding
52
+ comparator = Comparator.new
53
+ @db.collation 'foo', comparator
54
+ @db.execute('select data from ex order by 1 collate foo')
55
+
56
+ a, b = *comparator.calls.first
57
+
58
+ assert_equal Encoding.find('UTF-8'), a.encoding
59
+ assert_equal Encoding.find('UTF-8'), b.encoding
60
+ end
61
+
62
+ def test_encoding_default_internal
63
+ warn_before = $-w
64
+ $-w = false
65
+ before_enc = Encoding.default_internal
66
+
67
+ Encoding.default_internal = 'EUC-JP'
68
+ comparator = Comparator.new
69
+ @db.collation 'foo', comparator
70
+ @db.execute('select data from ex order by 1 collate foo')
71
+
72
+ a, b = *comparator.calls.first
73
+
74
+ assert_equal Encoding.find('EUC-JP'), a.encoding
75
+ assert_equal Encoding.find('EUC-JP'), b.encoding
76
+ ensure
77
+ Encoding.default_internal = before_enc
78
+ $-w = warn_before
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,350 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestDatabase < SQLite3::TestCase
5
+ attr_reader :db
6
+
7
+ def setup
8
+ @db = SQLite3::Database.new(':memory:')
9
+ end
10
+
11
+ def test_segv
12
+ assert_raises(TypeError) { SQLite3::Database.new 1 }
13
+ end
14
+
15
+ def test_bignum
16
+ num = 4907021672125087844
17
+ db.execute 'CREATE TABLE "employees" ("token" integer(8), "name" varchar(20) NOT NULL)'
18
+ db.execute "INSERT INTO employees(name, token) VALUES('employee-1', ?)", [num]
19
+ rows = db.execute 'select token from employees'
20
+ assert_equal num, rows.first.first
21
+ end
22
+
23
+ def test_blob
24
+ @db.execute("CREATE TABLE blobs ( id INTEGER, hash BLOB(10) )")
25
+ blob = Blob.new("foo\0bar")
26
+ @db.execute("INSERT INTO blobs VALUES (0, ?)", [blob])
27
+ assert_equal [[0, blob, blob.length, blob.length*2]], @db.execute("SELECT id, hash, length(hash), length(hex(hash)) FROM blobs")
28
+ end
29
+
30
+ def test_get_first_row
31
+ assert_equal [1], @db.get_first_row('SELECT 1')
32
+ end
33
+
34
+ def test_get_first_row_with_type_translation_and_hash_results
35
+ @db.results_as_hash = true
36
+ assert_equal({0=>1, "1"=>1}, @db.get_first_row('SELECT 1'))
37
+ end
38
+
39
+ def test_execute_with_type_translation_and_hash
40
+ @db.results_as_hash = true
41
+ rows = []
42
+ @db.execute('SELECT 1') { |row| rows << row }
43
+
44
+ assert_equal({0=>1, "1"=>1}, rows.first)
45
+ end
46
+
47
+ def test_encoding
48
+ assert @db.encoding, 'database has encoding'
49
+ end
50
+
51
+ def test_changes
52
+ @db.execute("CREATE TABLE items (id integer PRIMARY KEY AUTOINCREMENT, number integer)")
53
+ assert_equal 0, @db.changes
54
+ @db.execute("INSERT INTO items (number) VALUES (10)")
55
+ assert_equal 1, @db.changes
56
+ @db.execute_batch(
57
+ "UPDATE items SET number = (number + :nn) WHERE (number = :n)",
58
+ {"nn" => 20, "n" => 10})
59
+ assert_equal 1, @db.changes
60
+ assert_equal [[30]], @db.execute("select number from items")
61
+ end
62
+
63
+ def test_new
64
+ db = SQLite3::Database.new(':memory:')
65
+ assert db
66
+ end
67
+
68
+ def test_new_yields_self
69
+ thing = nil
70
+ SQLite3::Database.new(':memory:') do |db|
71
+ thing = db
72
+ end
73
+ assert_instance_of(SQLite3::Database, thing)
74
+ end
75
+
76
+ def test_new_with_options
77
+ # determine if Ruby is running on Big Endian platform
78
+ utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
79
+
80
+ if RUBY_VERSION >= "1.9"
81
+ db = SQLite3::Database.new(':memory:'.encode(utf16), :utf16 => true)
82
+ else
83
+ db = SQLite3::Database.new(Iconv.conv(utf16, 'UTF-8', ':memory:'),
84
+ :utf16 => true)
85
+ end
86
+ assert db
87
+ end
88
+
89
+ def test_close
90
+ db = SQLite3::Database.new(':memory:')
91
+ db.close
92
+ assert db.closed?
93
+ end
94
+
95
+ def test_block_closes_self
96
+ thing = nil
97
+ SQLite3::Database.new(':memory:') do |db|
98
+ thing = db
99
+ assert !thing.closed?
100
+ end
101
+ assert thing.closed?
102
+ end
103
+
104
+ def test_prepare
105
+ db = SQLite3::Database.new(':memory:')
106
+ stmt = db.prepare('select "hello world"')
107
+ assert_instance_of(SQLite3::Statement, stmt)
108
+ end
109
+
110
+ def test_total_changes
111
+ db = SQLite3::Database.new(':memory:')
112
+ db.execute("create table foo ( a integer primary key, b text )")
113
+ db.execute("insert into foo (b) values ('hello')")
114
+ assert_equal 1, db.total_changes
115
+ end
116
+
117
+ def test_execute_returns_list_of_hash
118
+ db = SQLite3::Database.new(':memory:', :results_as_hash => true)
119
+ db.execute("create table foo ( a integer primary key, b text )")
120
+ db.execute("insert into foo (b) values ('hello')")
121
+ rows = db.execute("select * from foo")
122
+ assert_equal [{0=>1, "a"=>1, "b"=>"hello", 1=>"hello"}], rows
123
+ end
124
+
125
+ def test_execute_yields_hash
126
+ db = SQLite3::Database.new(':memory:', :results_as_hash => true)
127
+ db.execute("create table foo ( a integer primary key, b text )")
128
+ db.execute("insert into foo (b) values ('hello')")
129
+ db.execute("select * from foo") do |row|
130
+ assert_equal({0=>1, "a"=>1, "b"=>"hello", 1=>"hello"}, row)
131
+ end
132
+ end
133
+
134
+ def test_table_info
135
+ db = SQLite3::Database.new(':memory:', :results_as_hash => true)
136
+ db.execute("create table foo ( a integer primary key, b text )")
137
+ info = [{
138
+ "name" => "a",
139
+ "pk" => 1,
140
+ "notnull" => 0,
141
+ "type" => "integer",
142
+ "dflt_value" => nil,
143
+ "cid" => 0
144
+ },
145
+ {
146
+ "name" => "b",
147
+ "pk" => 0,
148
+ "notnull" => 0,
149
+ "type" => "text",
150
+ "dflt_value" => nil,
151
+ "cid" => 1
152
+ }]
153
+ assert_equal info, db.table_info('foo')
154
+ end
155
+
156
+ def test_total_changes_closed
157
+ db = SQLite3::Database.new(':memory:')
158
+ db.close
159
+ assert_raise(SQLite3::Exception) do
160
+ db.total_changes
161
+ end
162
+ end
163
+
164
+ def test_trace_requires_opendb
165
+ @db.close
166
+ assert_raise(SQLite3::Exception) do
167
+ @db.trace { |x| }
168
+ end
169
+ end
170
+
171
+ def test_trace_with_block
172
+ result = nil
173
+ @db.trace { |sql| result = sql }
174
+ @db.execute "select 'foo'"
175
+ assert_equal "select 'foo'", result
176
+ end
177
+
178
+ def test_trace_with_object
179
+ obj = Class.new {
180
+ attr_accessor :result
181
+ def call sql; @result = sql end
182
+ }.new
183
+
184
+ @db.trace(obj)
185
+ @db.execute "select 'foo'"
186
+ assert_equal "select 'foo'", obj.result
187
+ end
188
+
189
+ def test_trace_takes_nil
190
+ @db.trace(nil)
191
+ @db.execute "select 'foo'"
192
+ end
193
+
194
+ def test_last_insert_row_id_closed
195
+ @db.close
196
+ assert_raise(SQLite3::Exception) do
197
+ @db.last_insert_row_id
198
+ end
199
+ end
200
+
201
+ def test_define_function
202
+ called_with = nil
203
+ @db.define_function("hello") do |value|
204
+ called_with = value
205
+ end
206
+ @db.execute("select hello(10)")
207
+ assert_equal 10, called_with
208
+ end
209
+
210
+ def test_call_func_arg_type
211
+ called_with = nil
212
+ @db.define_function("hello") do |b, c, d|
213
+ called_with = [b, c, d]
214
+ nil
215
+ end
216
+ @db.execute("select hello(2.2, 'foo', NULL)")
217
+ assert_equal [2.2, 'foo', nil], called_with
218
+ end
219
+
220
+ def test_define_varargs
221
+ called_with = nil
222
+ @db.define_function("hello") do |*args|
223
+ called_with = args
224
+ nil
225
+ end
226
+ @db.execute("select hello(2.2, 'foo', NULL)")
227
+ assert_equal [2.2, 'foo', nil], called_with
228
+ end
229
+
230
+ def test_call_func_blob
231
+ called_with = nil
232
+ @db.define_function("hello") do |a, b, c|
233
+ called_with = [a, b, c]
234
+ nil
235
+ end
236
+ blob = Blob.new("a\0fine\0kettle\0of\0fish")
237
+ @db.execute("select hello(?, length(?), length(?))", [blob, blob, blob])
238
+ assert_equal [blob, blob.length, 21], called_with
239
+ end
240
+
241
+ def test_function_return
242
+ @db.define_function("hello") { |a| 10 }
243
+ assert_equal [10], @db.execute("select hello('world')").first
244
+ end
245
+
246
+ def test_function_return_types
247
+ [10, 2.2, nil, "foo"].each do |thing|
248
+ @db.define_function("hello") { |a| thing }
249
+ assert_equal [thing], @db.execute("select hello('world')").first
250
+ end
251
+ end
252
+
253
+ def test_define_function_closed
254
+ @db.close
255
+ assert_raise(SQLite3::Exception) do
256
+ @db.define_function('foo') { }
257
+ end
258
+ end
259
+
260
+ def test_inerrupt_closed
261
+ @db.close
262
+ assert_raise(SQLite3::Exception) do
263
+ @db.interrupt
264
+ end
265
+ end
266
+
267
+ def test_define_aggregate
268
+ @db.execute "create table foo ( a integer primary key, b text )"
269
+ @db.execute "insert into foo ( b ) values ( 'foo' )"
270
+ @db.execute "insert into foo ( b ) values ( 'bar' )"
271
+ @db.execute "insert into foo ( b ) values ( 'baz' )"
272
+
273
+ acc = Class.new {
274
+ attr_reader :sum
275
+ alias :finalize :sum
276
+ def initialize
277
+ @sum = 0
278
+ end
279
+
280
+ def step a
281
+ @sum += a
282
+ end
283
+ }.new
284
+
285
+ @db.define_aggregator("accumulate", acc)
286
+ value = @db.get_first_value( "select accumulate(a) from foo" )
287
+ assert_equal 6, value
288
+ end
289
+
290
+ def test_authorizer_ok
291
+ @db.authorizer = Class.new {
292
+ def call action, a, b, c, d; true end
293
+ }.new
294
+ @db.prepare("select 'fooooo'")
295
+
296
+ @db.authorizer = Class.new {
297
+ def call action, a, b, c, d; 0 end
298
+ }.new
299
+ @db.prepare("select 'fooooo'")
300
+ end
301
+
302
+ def test_authorizer_ignore
303
+ @db.authorizer = Class.new {
304
+ def call action, a, b, c, d; nil end
305
+ }.new
306
+ stmt = @db.prepare("select 'fooooo'")
307
+ assert_equal nil, stmt.step
308
+ end
309
+
310
+ def test_authorizer_fail
311
+ @db.authorizer = Class.new {
312
+ def call action, a, b, c, d; false end
313
+ }.new
314
+ assert_raises(SQLite3::AuthorizationException) do
315
+ @db.prepare("select 'fooooo'")
316
+ end
317
+ end
318
+
319
+ def test_remove_auth
320
+ @db.authorizer = Class.new {
321
+ def call action, a, b, c, d; false end
322
+ }.new
323
+ assert_raises(SQLite3::AuthorizationException) do
324
+ @db.prepare("select 'fooooo'")
325
+ end
326
+
327
+ @db.authorizer = nil
328
+ @db.prepare("select 'fooooo'")
329
+ end
330
+
331
+ def test_close_with_open_statements
332
+ @db.prepare("select 'foo'")
333
+ assert_raises(SQLite3::BusyException) do
334
+ @db.close
335
+ end
336
+ end
337
+
338
+ def test_execute_with_empty_bind_params
339
+ assert_equal [['foo']], @db.execute("select 'foo'", [])
340
+ end
341
+
342
+ def test_query_with_named_bind_params
343
+ assert_equal [['foo']], @db.query("select :n", {'n' => 'foo'}).to_a
344
+ end
345
+
346
+ def test_execute_with_named_bind_params
347
+ assert_equal [['foo']], @db.execute("select :n", {'n' => 'foo'})
348
+ end
349
+ end
350
+ end