sqlite3 1.6.2-x86_64-darwin → 1.6.4-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,6 @@ require 'helper'
2
2
 
3
3
  module SQLite3
4
4
  class TestDeprecated < SQLite3::TestCase
5
- attr_reader :db
6
-
7
5
  def setup
8
6
  super
9
7
  @warn_before = $-w
@@ -15,10 +13,13 @@ module SQLite3
15
13
  def teardown
16
14
  super
17
15
  $-w = @warn_before
16
+ @db.close
18
17
  end
19
18
 
20
19
  def test_query_with_many_bind_params_not_nil
21
- assert_equal [[1, 2]], db.query('select ?, ?', 1, 2).to_a
20
+ rs = @db.query('select ?, ?', 1, 2)
21
+ assert_equal [[1, 2]], rs.to_a
22
+ rs.close
22
23
  end
23
24
 
24
25
  def test_execute_with_many_bind_params_not_nil
@@ -26,11 +27,15 @@ module SQLite3
26
27
  end
27
28
 
28
29
  def test_query_with_many_bind_params
29
- assert_equal [[nil, 1]], @db.query("select ?, ?", nil, 1).to_a
30
+ rs = @db.query("select ?, ?", nil, 1)
31
+ assert_equal [[nil, 1]], rs.to_a
32
+ rs.close
30
33
  end
31
34
 
32
35
  def test_query_with_nil_bind_params
33
- assert_equal [['foo']], @db.query("select 'foo'", nil).to_a
36
+ rs = @db.query("select 'foo'", nil)
37
+ assert_equal [['foo']], rs.to_a
38
+ rs.close
34
39
  end
35
40
 
36
41
  def test_execute_with_many_bind_params
@@ -11,6 +11,10 @@ module SQLite3
11
11
  @db.execute(@create);
12
12
  end
13
13
 
14
+ def teardown
15
+ @db.close
16
+ end
17
+
14
18
  def test_select_encoding_on_utf_16
15
19
  str = "foo"
16
20
  utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
@@ -24,6 +28,7 @@ module SQLite3
24
28
  assert_equal 1, stmt.to_a.length
25
29
  stmt.reset!
26
30
  end
31
+ stmt.close
27
32
  end
28
33
 
29
34
  def test_insert_encoding
@@ -39,6 +44,7 @@ module SQLite3
39
44
  stmt.to_a
40
45
  stmt.reset!
41
46
  end
47
+ stmt.close
42
48
 
43
49
  db.execute('select data from ex').flatten.each do |s|
44
50
  assert_equal str, s
@@ -55,6 +61,7 @@ module SQLite3
55
61
  stmt = @db.prepare('insert into ex(data) values (?)')
56
62
  stmt.bind_param 1, str
57
63
  stmt.step
64
+ stmt.close
58
65
 
59
66
  Encoding.default_internal = 'EUC-JP'
60
67
  string = @db.execute('select data from ex').first.first
@@ -73,6 +80,7 @@ module SQLite3
73
80
  stmt = @db.prepare('insert into foo(data) values (?)')
74
81
  stmt.bind_param(1, SQLite3::Blob.new(str))
75
82
  stmt.step
83
+ stmt.close
76
84
 
77
85
  string = @db.execute('select data from foo').first.first
78
86
  assert_equal Encoding.find('ASCII-8BIT'), string.encoding
@@ -85,6 +93,7 @@ module SQLite3
85
93
  stmt = @db.prepare('insert into foo(data) values (?)')
86
94
  stmt.bind_param(1, str.dup.force_encoding("ASCII-8BIT"))
87
95
  stmt.step
96
+ stmt.close
88
97
 
89
98
  string = @db.execute('select data from foo').first.first
90
99
  assert_equal Encoding.find('ASCII-8BIT'), string.encoding
@@ -97,6 +106,7 @@ module SQLite3
97
106
  stmt = @db.prepare('insert into foo(data) values (?)')
98
107
  stmt.bind_param(1, SQLite3::Blob.new(str))
99
108
  stmt.step
109
+ stmt.close
100
110
 
101
111
  string = @db.execute('select data from foo').first.first
102
112
  assert_equal Encoding.find('ASCII-8BIT'), string.encoding
@@ -77,10 +77,10 @@ class TC_Statement < SQLite3::TestCase
77
77
  def test_bind_param_with_various_types
78
78
  @db.transaction do
79
79
  @db.execute "create table all_types ( a integer primary key, b float, c string, d integer )"
80
- @db.execute "insert into all_types ( b, c, d ) values ( 1.4, 'hello', 68719476735 )"
80
+ @db.execute "insert into all_types ( b, c, d ) values ( 1.5, 'hello', 68719476735 )"
81
81
  end
82
82
 
83
- assert_equal 1, @db.execute( "select * from all_types where b = ?", 1.4 ).length
83
+ assert_equal 1, @db.execute( "select * from all_types where b = ?", 1.5 ).length
84
84
  assert_equal 1, @db.execute( "select * from all_types where c = ?", 'hello').length
85
85
  assert_equal 1, @db.execute( "select * from all_types where d = ?", 68719476735).length
86
86
  end
@@ -2,29 +2,38 @@ require 'helper'
2
2
 
3
3
  module SQLite3
4
4
  class TestResultSet < SQLite3::TestCase
5
+ def setup
6
+ @db = SQLite3::Database.new ':memory:'
7
+ super
8
+ end
9
+
10
+ def teardown
11
+ super
12
+ @db.close
13
+ end
14
+
5
15
  def test_each_hash
6
- db = SQLite3::Database.new ':memory:'
7
- db.execute "create table foo ( a integer primary key, b text )"
16
+ @db.execute "create table foo ( a integer primary key, b text )"
8
17
  list = ('a'..'z').to_a
9
18
  list.each do |t|
10
- db.execute "insert into foo (b) values (\"#{t}\")"
19
+ @db.execute "insert into foo (b) values (\"#{t}\")"
11
20
  end
12
21
 
13
- rs = db.prepare('select * from foo').execute
22
+ rs = @db.prepare('select * from foo').execute
14
23
  rs.each_hash do |hash|
15
24
  assert_equal list[hash['a'] - 1], hash['b']
16
25
  end
26
+ rs.close
17
27
  end
18
28
 
19
29
  def test_next_hash
20
- db = SQLite3::Database.new ':memory:'
21
- db.execute "create table foo ( a integer primary key, b text )"
30
+ @db.execute "create table foo ( a integer primary key, b text )"
22
31
  list = ('a'..'z').to_a
23
32
  list.each do |t|
24
- db.execute "insert into foo (b) values (\"#{t}\")"
33
+ @db.execute "insert into foo (b) values (\"#{t}\")"
25
34
  end
26
35
 
27
- rs = db.prepare('select * from foo').execute
36
+ rs = @db.prepare('select * from foo').execute
28
37
  rows = []
29
38
  while row = rs.next_hash
30
39
  rows << row
@@ -32,6 +41,7 @@ module SQLite3
32
41
  rows.each do |hash|
33
42
  assert_equal list[hash['a'] - 1], hash['b']
34
43
  end
44
+ rs.close
35
45
  end
36
46
  end
37
47
  end
@@ -7,6 +7,11 @@ module SQLite3
7
7
  @stmt = SQLite3::Statement.new(@db, "select 'foo'")
8
8
  end
9
9
 
10
+ def teardown
11
+ @stmt.close if !@stmt.closed?
12
+ @db.close
13
+ end
14
+
10
15
  def test_double_close_does_not_segv
11
16
  @db.execute 'CREATE TABLE "things" ("number" float NOT NULL)'
12
17
 
@@ -35,6 +40,8 @@ module SQLite3
35
40
  # Older versions of SQLite return:
36
41
  # column *column_name* is not unique
37
42
  assert_match(/(column(s)? .* (is|are) not unique|UNIQUE constraint failed: .*)/, exception.message)
43
+
44
+ stmt.close
38
45
  end
39
46
 
40
47
  ###
@@ -46,6 +53,7 @@ module SQLite3
46
53
  if stmt.respond_to?(:database_name)
47
54
  assert_equal 'main', stmt.database_name(0)
48
55
  end
56
+ stmt.close
49
57
  end
50
58
 
51
59
  def test_prepare_blob
@@ -77,6 +85,7 @@ module SQLite3
77
85
  def test_new_with_remainder
78
86
  stmt = SQLite3::Statement.new(@db, "select 'foo';bar")
79
87
  assert_equal 'bar', stmt.remainder
88
+ stmt.close
80
89
  end
81
90
 
82
91
  def test_empty_remainder
@@ -101,6 +110,7 @@ module SQLite3
101
110
  result = nil
102
111
  stmt.each { |x| result = x }
103
112
  assert_equal ['hello'], result
113
+ stmt.close
104
114
  end
105
115
 
106
116
  def test_bind_param_int
@@ -109,6 +119,7 @@ module SQLite3
109
119
  result = nil
110
120
  stmt.each { |x| result = x }
111
121
  assert_equal [10], result
122
+ stmt.close
112
123
  end
113
124
 
114
125
  def test_bind_nil
@@ -117,6 +128,7 @@ module SQLite3
117
128
  result = nil
118
129
  stmt.each { |x| result = x }
119
130
  assert_equal [nil], result
131
+ stmt.close
120
132
  end
121
133
 
122
134
  def test_bind_blob
@@ -125,6 +137,7 @@ module SQLite3
125
137
  stmt.bind_param(1, SQLite3::Blob.new('hello'))
126
138
  stmt.execute
127
139
  row = @db.execute('select * from foo')
140
+ stmt.close
128
141
 
129
142
  assert_equal ['hello'], row.first
130
143
  assert_equal ['blob'], row.first.types
@@ -136,6 +149,7 @@ module SQLite3
136
149
  result = nil
137
150
  stmt.each { |x| result = x }
138
151
  assert_equal [2 ** 31], result
152
+ stmt.close
139
153
  end
140
154
 
141
155
  def test_bind_double
@@ -144,6 +158,7 @@ module SQLite3
144
158
  result = nil
145
159
  stmt.each { |x| result = x }
146
160
  assert_equal [2.2], result
161
+ stmt.close
147
162
  end
148
163
 
149
164
  def test_named_bind
@@ -152,6 +167,7 @@ module SQLite3
152
167
  result = nil
153
168
  stmt.each { |x| result = x }
154
169
  assert_equal ['hello'], result
170
+ stmt.close
155
171
  end
156
172
 
157
173
  def test_named_bind_no_colon
@@ -160,6 +176,7 @@ module SQLite3
160
176
  result = nil
161
177
  stmt.each { |x| result = x }
162
178
  assert_equal ['hello'], result
179
+ stmt.close
163
180
  end
164
181
 
165
182
  def test_named_bind_symbol
@@ -168,6 +185,7 @@ module SQLite3
168
185
  result = nil
169
186
  stmt.each { |x| result = x }
170
187
  assert_equal ['hello'], result
188
+ stmt.close
171
189
  end
172
190
 
173
191
  def test_named_bind_not_found
@@ -175,6 +193,7 @@ module SQLite3
175
193
  assert_raises(SQLite3::Exception) do
176
194
  stmt.bind_param('bar', 'hello')
177
195
  end
196
+ stmt.close
178
197
  end
179
198
 
180
199
  def test_each
@@ -225,16 +244,19 @@ module SQLite3
225
244
  def test_bind_parameter_count
226
245
  stmt = SQLite3::Statement.new(@db, "select ?, ?, ?")
227
246
  assert_equal 3, stmt.bind_parameter_count
247
+ stmt.close
228
248
  end
229
249
 
230
250
  def test_execute_with_varargs
231
251
  stmt = @db.prepare('select ?, ?')
232
252
  assert_equal [[nil, nil]], stmt.execute(nil, nil).to_a
253
+ stmt.close
233
254
  end
234
255
 
235
256
  def test_execute_with_hash
236
257
  stmt = @db.prepare('select :n, :h')
237
258
  assert_equal [[10, nil]], stmt.execute('n' => 10, 'h' => nil).to_a
259
+ stmt.close
238
260
  end
239
261
 
240
262
  def test_with_error
@@ -244,6 +266,7 @@ module SQLite3
244
266
  stmt.execute('employee-1') rescue SQLite3::ConstraintException
245
267
  stmt.reset!
246
268
  assert stmt.execute('employee-2')
269
+ stmt.close
247
270
  end
248
271
 
249
272
  def test_clear_bindings!
@@ -258,6 +281,8 @@ module SQLite3
258
281
  while x = stmt.step
259
282
  assert_equal [nil, nil], x
260
283
  end
284
+
285
+ stmt.close
261
286
  end
262
287
  end
263
288
  end
@@ -8,6 +8,10 @@ module SQLite3
8
8
  "CREATE TABLE items (id integer PRIMARY KEY, number integer)")
9
9
  end
10
10
 
11
+ def teardown
12
+ @db.close
13
+ end
14
+
11
15
  def test_execute_insert
12
16
  ps = @db.prepare("INSERT INTO items (number) VALUES (:n)")
13
17
  ps.execute('n'=>10)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.4
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Jamis Buck
@@ -10,84 +10,8 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-03-27 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: minitest
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: '5.15'
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "~>"
27
- - !ruby/object:Gem::Version
28
- version: '5.15'
29
- - !ruby/object:Gem::Dependency
30
- name: rake-compiler
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: 1.2.0
36
- type: :development
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: 1.2.0
43
- - !ruby/object:Gem::Dependency
44
- name: rake-compiler-dock
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - '='
48
- - !ruby/object:Gem::Version
49
- version: 1.3.0
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - '='
55
- - !ruby/object:Gem::Version
56
- version: 1.3.0
57
- - !ruby/object:Gem::Dependency
58
- name: rdoc
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '4.0'
64
- - - "<"
65
- - !ruby/object:Gem::Version
66
- version: '7'
67
- type: :development
68
- prerelease: false
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: '4.0'
74
- - - "<"
75
- - !ruby/object:Gem::Version
76
- version: '7'
77
- - !ruby/object:Gem::Dependency
78
- name: psych
79
- requirement: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '4.0'
84
- type: :development
85
- prerelease: false
86
- version_requirements: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - "~>"
89
- - !ruby/object:Gem::Version
90
- version: '4.0'
13
+ date: 2023-08-26 00:00:00.000000000 Z
14
+ dependencies: []
91
15
  description: |-
92
16
  This module allows Ruby programs to interface with the SQLite3
93
17
  database engine (http://www.sqlite.org). You must have the
@@ -113,7 +37,9 @@ files:
113
37
  - CHANGELOG.md
114
38
  - CONTRIBUTING.md
115
39
  - ChangeLog.cvs
40
+ - FAQ.md
116
41
  - Gemfile
42
+ - INSTALLATION.md
117
43
  - LICENSE
118
44
  - LICENSE-DEPENDENCIES
119
45
  - README.md
@@ -131,9 +57,6 @@ files:
131
57
  - ext/sqlite3/sqlite3_ruby.h
132
58
  - ext/sqlite3/statement.c
133
59
  - ext/sqlite3/statement.h
134
- - faq/faq.md
135
- - faq/faq.rb
136
- - faq/faq.yml
137
60
  - lib/sqlite3.rb
138
61
  - lib/sqlite3/2.7/sqlite3_native.bundle
139
62
  - lib/sqlite3/3.0/sqlite3_native.bundle
data/faq/faq.rb DELETED
@@ -1,145 +0,0 @@
1
- require 'yaml'
2
- require 'redcloth'
3
-
4
- def process_faq_list( faqs )
5
- puts "<ul>"
6
- faqs.each do |faq|
7
- process_faq_list_item faq
8
- end
9
- puts "</ul>"
10
- end
11
-
12
- def process_faq_list_item( faq )
13
- question = faq.keys.first
14
- answer = faq.values.first
15
-
16
- print "<li>"
17
-
18
- question_text = RedCloth.new(question).to_html.gsub( %r{</?p>},"" )
19
- if answer.is_a?( Array )
20
- puts question_text
21
- process_faq_list answer
22
- else
23
- print "<a href='##{question.object_id}'>#{question_text}</a>"
24
- end
25
-
26
- puts "</li>"
27
- end
28
-
29
- def process_faq_descriptions( faqs, path=nil )
30
- faqs.each do |faq|
31
- process_faq_description faq, path
32
- end
33
- end
34
-
35
- def process_faq_description( faq, path )
36
- question = faq.keys.first
37
- path = ( path ? path + " " : "" ) + question
38
- answer = faq.values.first
39
-
40
- if answer.is_a?( Array )
41
- process_faq_descriptions( answer, path )
42
- else
43
- title = RedCloth.new( path ).to_html.gsub( %r{</?p>}, "" )
44
- answer = RedCloth.new( answer || "" )
45
-
46
- puts "<a name='#{question.object_id}'></a>"
47
- puts "<div class='faq-title'>#{title}</div>"
48
- puts "<div class='faq-answer'>#{add_api_links(answer.to_html)}</div>"
49
- end
50
- end
51
-
52
- API_OBJECTS = [ "Database", "Statement", "ResultSet",
53
- "ParsedStatement", "Pragmas", "Translator" ].inject( "(" ) { |acc,name|
54
- acc << "|" if acc.length > 1
55
- acc << name
56
- acc
57
- } + ")"
58
-
59
- def add_api_links( text )
60
- text.gsub( /#{API_OBJECTS}(#(\w+))?/ ) do
61
- disp_obj = obj = $1
62
-
63
- case obj
64
- when "Pragmas"; disp_obj = "Database"
65
- end
66
-
67
- method = $3
68
- s = "<a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/#{obj}.html'>#{disp_obj}"
69
- s << "##{method}" if method
70
- s << "</a>"
71
- s
72
- end
73
- end
74
-
75
- faqs = YAML.load( File.read( "faq.yml" ) )
76
-
77
- puts <<-EOF
78
- <html>
79
- <head>
80
- <title>SQLite3/Ruby FAQ</title>
81
- <style type="text/css">
82
- a, a:visited, a:active {
83
- color: #00F;
84
- text-decoration: none;
85
- }
86
-
87
- a:hover {
88
- text-decoration: underline;
89
- }
90
-
91
- .faq-list {
92
- color: #000;
93
- font-family: vera-sans, verdana, arial, sans-serif;
94
- }
95
-
96
- .faq-title {
97
- background: #007;
98
- color: #FFF;
99
- font-family: vera-sans, verdana, arial, sans-serif;
100
- padding-left: 1em;
101
- padding-top: 0.5em;
102
- padding-bottom: 0.5em;
103
- font-weight: bold;
104
- font-size: large;
105
- border: 1px solid #000;
106
- }
107
-
108
- .faq-answer {
109
- margin-left: 1em;
110
- color: #000;
111
- font-family: vera-sans, verdana, arial, sans-serif;
112
- }
113
-
114
- .faq-answer pre {
115
- margin-left: 1em;
116
- color: #000;
117
- background: #FFE;
118
- font-size: normal;
119
- border: 1px dotted #CCC;
120
- padding: 1em;
121
- }
122
-
123
- h1 {
124
- background: #005;
125
- color: #FFF;
126
- font-family: vera-sans, verdana, arial, sans-serif;
127
- padding-left: 1em;
128
- padding-top: 1em;
129
- padding-bottom: 1em;
130
- font-weight: bold;
131
- font-size: x-large;
132
- border: 1px solid #00F;
133
- }
134
- </style>
135
- </head>
136
- <body>
137
- <h1>SQLite/Ruby FAQ</h1>
138
- <div class="faq-list">
139
- EOF
140
-
141
- process_faq_list( faqs )
142
- puts "</div>"
143
- process_faq_descriptions( faqs )
144
-
145
- puts "</body></html>"