sqlite3 1.3.8-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.gemtest +0 -0
  2. data/API_CHANGES.rdoc +50 -0
  3. data/CHANGELOG.rdoc +265 -0
  4. data/ChangeLog.cvs +88 -0
  5. data/Gemfile +15 -0
  6. data/LICENSE +27 -0
  7. data/Manifest.txt +52 -0
  8. data/README.rdoc +95 -0
  9. data/Rakefile +10 -0
  10. data/ext/sqlite3/backup.c +168 -0
  11. data/ext/sqlite3/backup.h +15 -0
  12. data/ext/sqlite3/database.c +822 -0
  13. data/ext/sqlite3/database.h +15 -0
  14. data/ext/sqlite3/exception.c +94 -0
  15. data/ext/sqlite3/exception.h +8 -0
  16. data/ext/sqlite3/extconf.rb +51 -0
  17. data/ext/sqlite3/sqlite3.c +40 -0
  18. data/ext/sqlite3/sqlite3_ruby.h +53 -0
  19. data/ext/sqlite3/statement.c +439 -0
  20. data/ext/sqlite3/statement.h +16 -0
  21. data/faq/faq.rb +145 -0
  22. data/faq/faq.yml +426 -0
  23. data/lib/sqlite3.rb +10 -0
  24. data/lib/sqlite3/2.0/sqlite3_native.so +0 -0
  25. data/lib/sqlite3/constants.rb +49 -0
  26. data/lib/sqlite3/database.rb +579 -0
  27. data/lib/sqlite3/errors.rb +44 -0
  28. data/lib/sqlite3/pragmas.rb +280 -0
  29. data/lib/sqlite3/resultset.rb +195 -0
  30. data/lib/sqlite3/statement.rb +144 -0
  31. data/lib/sqlite3/translator.rb +118 -0
  32. data/lib/sqlite3/value.rb +57 -0
  33. data/lib/sqlite3/version.rb +25 -0
  34. data/setup.rb +1333 -0
  35. data/tasks/faq.rake +9 -0
  36. data/tasks/gem.rake +37 -0
  37. data/tasks/native.rake +45 -0
  38. data/tasks/vendor_sqlite3.rake +87 -0
  39. data/test/helper.rb +18 -0
  40. data/test/test_backup.rb +33 -0
  41. data/test/test_collation.rb +82 -0
  42. data/test/test_database.rb +350 -0
  43. data/test/test_database_readonly.rb +29 -0
  44. data/test/test_deprecated.rb +44 -0
  45. data/test/test_encoding.rb +121 -0
  46. data/test/test_integration.rb +555 -0
  47. data/test/test_integration_open_close.rb +30 -0
  48. data/test/test_integration_pending.rb +115 -0
  49. data/test/test_integration_resultset.rb +159 -0
  50. data/test/test_integration_statement.rb +194 -0
  51. data/test/test_result_set.rb +37 -0
  52. data/test/test_sqlite3.rb +9 -0
  53. data/test/test_statement.rb +256 -0
  54. data/test/test_statement_execute.rb +35 -0
  55. metadata +246 -0
@@ -0,0 +1,37 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestResultSet < SQLite3::TestCase
5
+ def test_each_hash
6
+ db = SQLite3::Database.new ':memory:'
7
+ db.execute "create table foo ( a integer primary key, b text )"
8
+ list = ('a'..'z').to_a
9
+ list.each do |t|
10
+ db.execute "insert into foo (b) values (\"#{t}\")"
11
+ end
12
+
13
+ rs = db.prepare('select * from foo').execute
14
+ rs.each_hash do |hash|
15
+ assert_equal list[hash['a'] - 1], hash['b']
16
+ end
17
+ end
18
+
19
+ def test_next_hash
20
+ db = SQLite3::Database.new ':memory:'
21
+ db.execute "create table foo ( a integer primary key, b text )"
22
+ list = ('a'..'z').to_a
23
+ list.each do |t|
24
+ db.execute "insert into foo (b) values (\"#{t}\")"
25
+ end
26
+
27
+ rs = db.prepare('select * from foo').execute
28
+ rows = []
29
+ while row = rs.next_hash
30
+ rows << row
31
+ end
32
+ rows.each do |hash|
33
+ assert_equal list[hash['a'] - 1], hash['b']
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestSQLite3 < SQLite3::TestCase
5
+ def test_libversion
6
+ assert_not_nil SQLite3.libversion
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,256 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestStatement < SQLite3::TestCase
5
+ def setup
6
+ @db = SQLite3::Database.new(':memory:')
7
+ @stmt = SQLite3::Statement.new(@db, "select 'foo'")
8
+ end
9
+
10
+ def test_double_close_does_not_segv
11
+ @db.execute 'CREATE TABLE "things" ("number" float NOT NULL)'
12
+
13
+ stmt = @db.prepare 'INSERT INTO things (number) VALUES (?)'
14
+ assert_raises(SQLite3::ConstraintException) { stmt.execute(nil) }
15
+
16
+ stmt.close
17
+
18
+ assert_raises(SQLite3::Exception) { stmt.close }
19
+ end
20
+
21
+ def test_raises_type_error
22
+ assert_raises(TypeError) do
23
+ SQLite3::Statement.new( @db, nil )
24
+ end
25
+ end
26
+
27
+ def test_insert_duplicate_records
28
+ @db.execute 'CREATE TABLE "things" ("name" varchar(20) CONSTRAINT "index_things_on_name" UNIQUE)'
29
+ stmt = @db.prepare("INSERT INTO things(name) VALUES(?)")
30
+ stmt.execute('ruby')
31
+
32
+ exception = assert_raises(SQLite3::ConstraintException) { stmt.execute('ruby') }
33
+ assert_match /column(s)? .* (is|are) not unique/, exception.message
34
+ end
35
+
36
+ ###
37
+ # This method may not exist depending on how sqlite3 was compiled
38
+ def test_database_name
39
+ @db.execute('create table foo(text BLOB)')
40
+ @db.execute('insert into foo(text) values (?)',SQLite3::Blob.new('hello'))
41
+ stmt = @db.prepare('select text from foo')
42
+ if stmt.respond_to?(:database_name)
43
+ assert_equal 'main', stmt.database_name(0)
44
+ end
45
+ end
46
+
47
+ def test_prepare_blob
48
+ @db.execute('create table foo(text BLOB)')
49
+ stmt = @db.prepare('insert into foo(text) values (?)')
50
+ stmt.bind_param(1, SQLite3::Blob.new('hello'))
51
+ stmt.step
52
+ stmt.close
53
+ end
54
+
55
+ def test_select_blob
56
+ @db.execute('create table foo(text BLOB)')
57
+ @db.execute('insert into foo(text) values (?)',SQLite3::Blob.new('hello'))
58
+ assert_equal 'hello', @db.execute('select * from foo').first.first
59
+ end
60
+
61
+ def test_new
62
+ assert @stmt
63
+ end
64
+
65
+ def test_new_closed_handle
66
+ @db = SQLite3::Database.new(':memory:')
67
+ @db.close
68
+ assert_raises(ArgumentError) do
69
+ SQLite3::Statement.new(@db, 'select "foo"')
70
+ end
71
+ end
72
+
73
+ def test_new_with_remainder
74
+ stmt = SQLite3::Statement.new(@db, "select 'foo';bar")
75
+ assert_equal 'bar', stmt.remainder
76
+ end
77
+
78
+ def test_empty_remainder
79
+ assert_equal '', @stmt.remainder
80
+ end
81
+
82
+ def test_close
83
+ @stmt.close
84
+ assert @stmt.closed?
85
+ end
86
+
87
+ def test_double_close
88
+ @stmt.close
89
+ assert_raises(SQLite3::Exception) do
90
+ @stmt.close
91
+ end
92
+ end
93
+
94
+ def test_bind_param_string
95
+ stmt = SQLite3::Statement.new(@db, "select ?")
96
+ stmt.bind_param(1, "hello")
97
+ result = nil
98
+ stmt.each { |x| result = x }
99
+ assert_equal ['hello'], result
100
+ end
101
+
102
+ def test_bind_param_int
103
+ stmt = SQLite3::Statement.new(@db, "select ?")
104
+ stmt.bind_param(1, 10)
105
+ result = nil
106
+ stmt.each { |x| result = x }
107
+ assert_equal [10], result
108
+ end
109
+
110
+ def test_bind_nil
111
+ stmt = SQLite3::Statement.new(@db, "select ?")
112
+ stmt.bind_param(1, nil)
113
+ result = nil
114
+ stmt.each { |x| result = x }
115
+ assert_equal [nil], result
116
+ end
117
+
118
+ def test_bind_blobs
119
+ end
120
+
121
+ def test_bind_64
122
+ stmt = SQLite3::Statement.new(@db, "select ?")
123
+ stmt.bind_param(1, 2 ** 31)
124
+ result = nil
125
+ stmt.each { |x| result = x }
126
+ assert_equal [2 ** 31], result
127
+ end
128
+
129
+ def test_bind_double
130
+ stmt = SQLite3::Statement.new(@db, "select ?")
131
+ stmt.bind_param(1, 2.2)
132
+ result = nil
133
+ stmt.each { |x| result = x }
134
+ assert_equal [2.2], result
135
+ end
136
+
137
+ def test_named_bind
138
+ stmt = SQLite3::Statement.new(@db, "select :foo")
139
+ stmt.bind_param(':foo', 'hello')
140
+ result = nil
141
+ stmt.each { |x| result = x }
142
+ assert_equal ['hello'], result
143
+ end
144
+
145
+ def test_named_bind_no_colon
146
+ stmt = SQLite3::Statement.new(@db, "select :foo")
147
+ stmt.bind_param('foo', 'hello')
148
+ result = nil
149
+ stmt.each { |x| result = x }
150
+ assert_equal ['hello'], result
151
+ end
152
+
153
+ def test_named_bind_symbol
154
+ stmt = SQLite3::Statement.new(@db, "select :foo")
155
+ stmt.bind_param(:foo, 'hello')
156
+ result = nil
157
+ stmt.each { |x| result = x }
158
+ assert_equal ['hello'], result
159
+ end
160
+
161
+ def test_named_bind_not_found
162
+ stmt = SQLite3::Statement.new(@db, "select :foo")
163
+ assert_raises(SQLite3::Exception) do
164
+ stmt.bind_param('bar', 'hello')
165
+ end
166
+ end
167
+
168
+ def test_each
169
+ r = nil
170
+ @stmt.each do |row|
171
+ r = row
172
+ end
173
+ assert_equal(['foo'], r)
174
+ end
175
+
176
+ def test_reset!
177
+ r = []
178
+ @stmt.each { |row| r << row }
179
+ @stmt.reset!
180
+ @stmt.each { |row| r << row }
181
+ assert_equal [['foo'], ['foo']], r
182
+ end
183
+
184
+ def test_step
185
+ r = @stmt.step
186
+ assert_equal ['foo'], r
187
+ end
188
+
189
+ def test_tainted
190
+ r = @stmt.step
191
+ assert r.first.tainted?
192
+ end
193
+
194
+ def test_step_twice
195
+ assert_not_nil @stmt.step
196
+ assert !@stmt.done?
197
+ assert_nil @stmt.step
198
+ assert @stmt.done?
199
+
200
+ @stmt.reset!
201
+ assert !@stmt.done?
202
+ end
203
+
204
+ def test_step_never_moves_past_done
205
+ 10.times { @stmt.step }
206
+ @stmt.done?
207
+ end
208
+
209
+ def test_column_count
210
+ assert_equal 1, @stmt.column_count
211
+ end
212
+
213
+ def test_column_name
214
+ assert_equal "'foo'", @stmt.column_name(0)
215
+ assert_equal nil, @stmt.column_name(10)
216
+ end
217
+
218
+ def test_bind_parameter_count
219
+ stmt = SQLite3::Statement.new(@db, "select ?, ?, ?")
220
+ assert_equal 3, stmt.bind_parameter_count
221
+ end
222
+
223
+ def test_execute_with_varargs
224
+ stmt = @db.prepare('select ?, ?')
225
+ assert_equal [[nil, nil]], stmt.execute(nil, nil).to_a
226
+ end
227
+
228
+ def test_execute_with_hash
229
+ stmt = @db.prepare('select :n, :h')
230
+ assert_equal [[10, nil]], stmt.execute('n' => 10, 'h' => nil).to_a
231
+ end
232
+
233
+ def test_with_error
234
+ @db.execute('CREATE TABLE "employees" ("name" varchar(20) NOT NULL CONSTRAINT "index_employees_on_name" UNIQUE)')
235
+ stmt = @db.prepare("INSERT INTO Employees(name) VALUES(?)")
236
+ stmt.execute('employee-1')
237
+ stmt.execute('employee-1') rescue SQLite3::ConstraintException
238
+ stmt.reset!
239
+ assert stmt.execute('employee-2')
240
+ end
241
+
242
+ def test_clear_bindings
243
+ stmt = @db.prepare('select ?, ?')
244
+ stmt.bind_param 1, "foo"
245
+ stmt.bind_param 2, "bar"
246
+
247
+ # We can't fetch bound parameters back out of sqlite3, so just call
248
+ # the clear_bindings! method and assert that nil is returned
249
+ stmt.clear_bindings!
250
+
251
+ while x = stmt.step
252
+ assert_equal [nil, nil], x
253
+ end
254
+ end
255
+ end
256
+ end
@@ -0,0 +1,35 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestStatementExecute < SQLite3::TestCase
5
+ def setup
6
+ @db = SQLite3::Database.new(':memory:')
7
+ @db.execute_batch(
8
+ "CREATE TABLE items (id integer PRIMARY KEY, number integer)")
9
+ end
10
+
11
+ def test_execute_insert
12
+ ps = @db.prepare("INSERT INTO items (number) VALUES (:n)")
13
+ ps.execute('n'=>10)
14
+ assert_equal 1, @db.get_first_value("SELECT count(*) FROM items")
15
+ ps.close
16
+ end
17
+
18
+ def test_execute_update
19
+ @db.execute("INSERT INTO items (number) VALUES (?)", [10])
20
+
21
+ ps = @db.prepare("UPDATE items SET number = :new WHERE number = :old")
22
+ ps.execute('old'=>10, 'new'=>20)
23
+ assert_equal 20, @db.get_first_value("SELECT number FROM items")
24
+ ps.close
25
+ end
26
+
27
+ def test_execute_delete
28
+ @db.execute("INSERT INTO items (number) VALUES (?)", [20])
29
+ ps = @db.prepare("DELETE FROM items WHERE number = :n")
30
+ ps.execute('n' => 20)
31
+ assert_equal 0, @db.get_first_value("SELECT count(*) FROM items")
32
+ ps.close
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,246 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sqlite3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 8
10
+ version: 1.3.8
11
+ platform: x64-mingw32
12
+ authors:
13
+ - Jamis Buck
14
+ - Luis Lavena
15
+ - Aaron Patterson
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2013-08-17 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 31
29
+ segments:
30
+ - 5
31
+ - 0
32
+ version: "5.0"
33
+ name: minitest
34
+ prerelease: false
35
+ type: :development
36
+ requirement: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 27
44
+ segments:
45
+ - 4
46
+ - 0
47
+ version: "4.0"
48
+ name: rdoc
49
+ prerelease: false
50
+ type: :development
51
+ requirement: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 57
59
+ segments:
60
+ - 0
61
+ - 9
62
+ - 1
63
+ version: 0.9.1
64
+ name: rake-compiler
65
+ prerelease: false
66
+ type: :development
67
+ requirement: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 9
75
+ segments:
76
+ - 0
77
+ - 5
78
+ - 1
79
+ version: 0.5.1
80
+ name: mini_portile
81
+ prerelease: false
82
+ type: :development
83
+ requirement: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ version_requirements: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ hash: 15
91
+ segments:
92
+ - 1
93
+ - 0
94
+ version: "1.0"
95
+ name: hoe-bundler
96
+ prerelease: false
97
+ type: :development
98
+ requirement: *id005
99
+ - !ruby/object:Gem::Dependency
100
+ version_requirements: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ hash: 9
106
+ segments:
107
+ - 3
108
+ - 7
109
+ version: "3.7"
110
+ name: hoe
111
+ prerelease: false
112
+ type: :development
113
+ requirement: *id006
114
+ description: |-
115
+ This module allows Ruby programs to interface with the SQLite3
116
+ database engine (http://www.sqlite.org). You must have the
117
+ SQLite engine installed in order to build this module.
118
+
119
+ Note that this module is only compatible with SQLite 3.6.16 or newer.
120
+ email:
121
+ - jamis@37signals.com
122
+ - luislavena@gmail.com
123
+ - aaron@tenderlovemaking.com
124
+ executables: []
125
+
126
+ extensions: []
127
+
128
+ extra_rdoc_files:
129
+ - API_CHANGES.rdoc
130
+ - CHANGELOG.rdoc
131
+ - Manifest.txt
132
+ - README.rdoc
133
+ - ext/sqlite3/backup.c
134
+ - ext/sqlite3/database.c
135
+ - ext/sqlite3/exception.c
136
+ - ext/sqlite3/sqlite3.c
137
+ - ext/sqlite3/statement.c
138
+ files:
139
+ - API_CHANGES.rdoc
140
+ - CHANGELOG.rdoc
141
+ - ChangeLog.cvs
142
+ - Gemfile
143
+ - LICENSE
144
+ - Manifest.txt
145
+ - README.rdoc
146
+ - Rakefile
147
+ - ext/sqlite3/backup.c
148
+ - ext/sqlite3/backup.h
149
+ - ext/sqlite3/database.c
150
+ - ext/sqlite3/database.h
151
+ - ext/sqlite3/exception.c
152
+ - ext/sqlite3/exception.h
153
+ - ext/sqlite3/extconf.rb
154
+ - ext/sqlite3/sqlite3.c
155
+ - ext/sqlite3/sqlite3_ruby.h
156
+ - ext/sqlite3/statement.c
157
+ - ext/sqlite3/statement.h
158
+ - faq/faq.rb
159
+ - faq/faq.yml
160
+ - lib/sqlite3.rb
161
+ - lib/sqlite3/constants.rb
162
+ - lib/sqlite3/database.rb
163
+ - lib/sqlite3/errors.rb
164
+ - lib/sqlite3/pragmas.rb
165
+ - lib/sqlite3/resultset.rb
166
+ - lib/sqlite3/statement.rb
167
+ - lib/sqlite3/translator.rb
168
+ - lib/sqlite3/value.rb
169
+ - lib/sqlite3/version.rb
170
+ - setup.rb
171
+ - tasks/faq.rake
172
+ - tasks/gem.rake
173
+ - tasks/native.rake
174
+ - tasks/vendor_sqlite3.rake
175
+ - test/helper.rb
176
+ - test/test_backup.rb
177
+ - test/test_collation.rb
178
+ - test/test_database.rb
179
+ - test/test_database_readonly.rb
180
+ - test/test_deprecated.rb
181
+ - test/test_encoding.rb
182
+ - test/test_integration.rb
183
+ - test/test_integration_open_close.rb
184
+ - test/test_integration_pending.rb
185
+ - test/test_integration_resultset.rb
186
+ - test/test_integration_statement.rb
187
+ - test/test_result_set.rb
188
+ - test/test_sqlite3.rb
189
+ - test/test_statement.rb
190
+ - test/test_statement_execute.rb
191
+ - .gemtest
192
+ - lib/sqlite3/2.0/sqlite3_native.so
193
+ homepage: http://github.com/luislavena/sqlite3-ruby
194
+ licenses:
195
+ - MIT
196
+ post_install_message:
197
+ rdoc_options:
198
+ - --main
199
+ - README.rdoc
200
+ require_paths:
201
+ - lib
202
+ required_ruby_version: !ruby/object:Gem::Requirement
203
+ none: false
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ hash: 57
208
+ segments:
209
+ - 1
210
+ - 8
211
+ - 7
212
+ version: 1.8.7
213
+ required_rubygems_version: !ruby/object:Gem::Requirement
214
+ none: false
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ hash: 17
219
+ segments:
220
+ - 1
221
+ - 3
222
+ - 5
223
+ version: 1.3.5
224
+ requirements: []
225
+
226
+ rubyforge_project: sqlite3
227
+ rubygems_version: 1.8.25
228
+ signing_key:
229
+ specification_version: 3
230
+ summary: This module allows Ruby programs to interface with the SQLite3 database engine (http://www.sqlite.org)
231
+ test_files:
232
+ - test/test_backup.rb
233
+ - test/test_collation.rb
234
+ - test/test_database.rb
235
+ - test/test_database_readonly.rb
236
+ - test/test_deprecated.rb
237
+ - test/test_encoding.rb
238
+ - test/test_integration.rb
239
+ - test/test_integration_open_close.rb
240
+ - test/test_integration_pending.rb
241
+ - test/test_integration_resultset.rb
242
+ - test/test_integration_statement.rb
243
+ - test/test_result_set.rb
244
+ - test/test_sqlite3.rb
245
+ - test/test_statement.rb
246
+ - test/test_statement_execute.rb