dawanda-sqlite3 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.gemtest +0 -0
  2. data/API_CHANGES.rdoc +50 -0
  3. data/CHANGELOG.rdoc +184 -0
  4. data/ChangeLog.cvs +88 -0
  5. data/LICENSE +27 -0
  6. data/Manifest.txt +50 -0
  7. data/README.rdoc +95 -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 +762 -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 +41 -0
  16. data/ext/sqlite3/sqlite3.c +40 -0
  17. data/ext/sqlite3/sqlite3_ruby.h +44 -0
  18. data/ext/sqlite3/statement.c +418 -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 +587 -0
  25. data/lib/sqlite3/errors.rb +44 -0
  26. data/lib/sqlite3/pragmas.rb +280 -0
  27. data/lib/sqlite3/resultset.rb +126 -0
  28. data/lib/sqlite3/statement.rb +148 -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 +31 -0
  35. data/tasks/native.rake +61 -0
  36. data/tasks/vendor_sqlite3.rake +104 -0
  37. data/test/helper.rb +3 -0
  38. data/test/test_backup.rb +33 -0
  39. data/test/test_collation.rb +82 -0
  40. data/test/test_database.rb +319 -0
  41. data/test/test_database_readonly.rb +29 -0
  42. data/test/test_deprecated.rb +37 -0
  43. data/test/test_encoding.rb +119 -0
  44. data/test/test_integration.rb +544 -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 +156 -0
  48. data/test/test_integration_statement.rb +194 -0
  49. data/test/test_sqlite3.rb +9 -0
  50. data/test/test_statement.rb +213 -0
  51. data/test/test_statement_execute.rb +35 -0
  52. metadata +184 -0
@@ -0,0 +1,9 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestSQLite3 < Test::Unit::TestCase
5
+ def test_libversion
6
+ assert_not_nil SQLite3.libversion
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,213 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestStatement < Test::Unit::TestCase
5
+ def setup
6
+ @db = SQLite3::Database.new(':memory:')
7
+ @stmt = SQLite3::Statement.new(@db, "select 'foo'")
8
+ end
9
+
10
+ def test_raises_type_error
11
+ assert_raises(TypeError) do
12
+ SQLite3::Statement.new( @db, nil )
13
+ end
14
+ end
15
+
16
+ ###
17
+ # This method may not exist depending on how sqlite3 was compiled
18
+ def test_database_name
19
+ @db.execute('create table foo(text BLOB)')
20
+ @db.execute('insert into foo(text) values (?)',SQLite3::Blob.new('hello'))
21
+ stmt = @db.prepare('select text from foo')
22
+ if stmt.respond_to?(:database_name)
23
+ assert_equal 'main', stmt.database_name(0)
24
+ end
25
+ end
26
+
27
+ def test_prepare_blob
28
+ @db.execute('create table foo(text BLOB)')
29
+ stmt = @db.prepare('insert into foo(text) values (?)')
30
+ stmt.bind_param(1, SQLite3::Blob.new('hello'))
31
+ stmt.step
32
+ stmt.close
33
+ end
34
+
35
+ def test_select_blob
36
+ @db.execute('create table foo(text BLOB)')
37
+ @db.execute('insert into foo(text) values (?)',SQLite3::Blob.new('hello'))
38
+ assert_equal 'hello', @db.execute('select * from foo').first.first
39
+ end
40
+
41
+ def test_new
42
+ assert @stmt
43
+ end
44
+
45
+ def test_new_closed_handle
46
+ @db = SQLite3::Database.new(':memory:')
47
+ @db.close
48
+ assert_raises(ArgumentError) do
49
+ SQLite3::Statement.new(@db, 'select "foo"')
50
+ end
51
+ end
52
+
53
+ def test_new_with_remainder
54
+ stmt = SQLite3::Statement.new(@db, "select 'foo';bar")
55
+ assert_equal 'bar', stmt.remainder
56
+ end
57
+
58
+ def test_empty_remainder
59
+ assert_equal '', @stmt.remainder
60
+ end
61
+
62
+ def test_close
63
+ @stmt.close
64
+ assert @stmt.closed?
65
+ end
66
+
67
+ def test_double_close
68
+ @stmt.close
69
+ assert_raises(SQLite3::Exception) do
70
+ @stmt.close
71
+ end
72
+ end
73
+
74
+ def test_bind_param_string
75
+ stmt = SQLite3::Statement.new(@db, "select ?")
76
+ stmt.bind_param(1, "hello")
77
+ result = nil
78
+ stmt.each { |x| result = x }
79
+ assert_equal ['hello'], result
80
+ end
81
+
82
+ def test_bind_param_int
83
+ stmt = SQLite3::Statement.new(@db, "select ?")
84
+ stmt.bind_param(1, 10)
85
+ result = nil
86
+ stmt.each { |x| result = x }
87
+ assert_equal [10], result
88
+ end
89
+
90
+ def test_bind_nil
91
+ stmt = SQLite3::Statement.new(@db, "select ?")
92
+ stmt.bind_param(1, nil)
93
+ result = nil
94
+ stmt.each { |x| result = x }
95
+ assert_equal [nil], result
96
+ end
97
+
98
+ def test_bind_blobs
99
+ end
100
+
101
+ def test_bind_64
102
+ stmt = SQLite3::Statement.new(@db, "select ?")
103
+ stmt.bind_param(1, 2 ** 31)
104
+ result = nil
105
+ stmt.each { |x| result = x }
106
+ assert_equal [2 ** 31], result
107
+ end
108
+
109
+ def test_bind_double
110
+ stmt = SQLite3::Statement.new(@db, "select ?")
111
+ stmt.bind_param(1, 2.2)
112
+ result = nil
113
+ stmt.each { |x| result = x }
114
+ assert_equal [2.2], result
115
+ end
116
+
117
+ def test_named_bind
118
+ stmt = SQLite3::Statement.new(@db, "select :foo")
119
+ stmt.bind_param(':foo', 'hello')
120
+ result = nil
121
+ stmt.each { |x| result = x }
122
+ assert_equal ['hello'], result
123
+ end
124
+
125
+ def test_named_bind_no_colon
126
+ stmt = SQLite3::Statement.new(@db, "select :foo")
127
+ stmt.bind_param('foo', 'hello')
128
+ result = nil
129
+ stmt.each { |x| result = x }
130
+ assert_equal ['hello'], result
131
+ end
132
+
133
+ def test_named_bind_symbol
134
+ stmt = SQLite3::Statement.new(@db, "select :foo")
135
+ stmt.bind_param(:foo, 'hello')
136
+ result = nil
137
+ stmt.each { |x| result = x }
138
+ assert_equal ['hello'], result
139
+ end
140
+
141
+ def test_named_bind_not_found
142
+ stmt = SQLite3::Statement.new(@db, "select :foo")
143
+ assert_raises(SQLite3::Exception) do
144
+ stmt.bind_param('bar', 'hello')
145
+ end
146
+ end
147
+
148
+ def test_each
149
+ r = nil
150
+ @stmt.each do |row|
151
+ r = row
152
+ end
153
+ assert_equal(['foo'], r)
154
+ end
155
+
156
+ def test_reset!
157
+ r = []
158
+ @stmt.each { |row| r << row }
159
+ @stmt.reset!
160
+ @stmt.each { |row| r << row }
161
+ assert_equal [['foo'], ['foo']], r
162
+ end
163
+
164
+ def test_step
165
+ r = @stmt.step
166
+ assert_equal ['foo'], r
167
+ end
168
+
169
+ def test_tainted
170
+ r = @stmt.step
171
+ assert r.first.tainted?
172
+ end
173
+
174
+ def test_step_twice
175
+ assert_not_nil @stmt.step
176
+ assert !@stmt.done?
177
+ assert_nil @stmt.step
178
+ assert @stmt.done?
179
+
180
+ @stmt.reset!
181
+ assert !@stmt.done?
182
+ end
183
+
184
+ def test_step_never_moves_past_done
185
+ 10.times { @stmt.step }
186
+ @stmt.done?
187
+ end
188
+
189
+ def test_column_count
190
+ assert_equal 1, @stmt.column_count
191
+ end
192
+
193
+ def test_column_name
194
+ assert_equal "'foo'", @stmt.column_name(0)
195
+ assert_equal nil, @stmt.column_name(10)
196
+ end
197
+
198
+ def test_bind_parameter_count
199
+ stmt = SQLite3::Statement.new(@db, "select ?, ?, ?")
200
+ assert_equal 3, stmt.bind_parameter_count
201
+ end
202
+
203
+ def test_execute_with_varargs
204
+ stmt = @db.prepare('select ?, ?')
205
+ assert_equal [[nil, nil]], stmt.execute(nil, nil).to_a
206
+ end
207
+
208
+ def test_execute_with_hash
209
+ stmt = @db.prepare('select :n, :h')
210
+ assert_equal [[10, nil]], stmt.execute('n' => 10, 'h' => nil).to_a
211
+ end
212
+ end
213
+ end
@@ -0,0 +1,35 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestStatementExecute < Test::Unit::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,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dawanda-sqlite3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 3
10
+ version: 1.3.3
11
+ platform: ruby
12
+ authors:
13
+ - Jamis Buck
14
+ - Luis Lavena
15
+ - Aaron Patterson
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2011-04-14 00:00:00 +02:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ - 7
33
+ - 0
34
+ version: 0.7.0
35
+ type: :development
36
+ requirement: *id001
37
+ name: rake-compiler
38
+ prerelease: false
39
+ - !ruby/object:Gem::Dependency
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 35
46
+ segments:
47
+ - 2
48
+ - 9
49
+ - 4
50
+ version: 2.9.4
51
+ type: :development
52
+ requirement: *id002
53
+ name: hoe
54
+ prerelease: false
55
+ description: |-
56
+ This module allows Ruby programs to interface with the SQLite3
57
+ database engine (http://www.sqlite.org). You must have the
58
+ SQLite engine installed in order to build this module.
59
+
60
+ Note that this module is NOT compatible with SQLite 2.x.
61
+ email:
62
+ - jamis@37signals.com
63
+ - luislavena@gmail.com
64
+ - aaron@tenderlovemaking.com
65
+ executables: []
66
+
67
+ extensions:
68
+ - ext/sqlite3/extconf.rb
69
+ extra_rdoc_files:
70
+ - Manifest.txt
71
+ - README.rdoc
72
+ - API_CHANGES.rdoc
73
+ - CHANGELOG.rdoc
74
+ - ext/sqlite3/database.c
75
+ - ext/sqlite3/exception.c
76
+ - ext/sqlite3/statement.c
77
+ - ext/sqlite3/backup.c
78
+ - ext/sqlite3/sqlite3.c
79
+ files:
80
+ - API_CHANGES.rdoc
81
+ - CHANGELOG.rdoc
82
+ - ChangeLog.cvs
83
+ - LICENSE
84
+ - Manifest.txt
85
+ - README.rdoc
86
+ - Rakefile
87
+ - ext/sqlite3/backup.c
88
+ - ext/sqlite3/backup.h
89
+ - ext/sqlite3/database.c
90
+ - ext/sqlite3/database.h
91
+ - ext/sqlite3/exception.c
92
+ - ext/sqlite3/exception.h
93
+ - ext/sqlite3/extconf.rb
94
+ - ext/sqlite3/sqlite3.c
95
+ - ext/sqlite3/sqlite3_ruby.h
96
+ - ext/sqlite3/statement.c
97
+ - ext/sqlite3/statement.h
98
+ - faq/faq.rb
99
+ - faq/faq.yml
100
+ - lib/sqlite3.rb
101
+ - lib/sqlite3/constants.rb
102
+ - lib/sqlite3/database.rb
103
+ - lib/sqlite3/errors.rb
104
+ - lib/sqlite3/pragmas.rb
105
+ - lib/sqlite3/resultset.rb
106
+ - lib/sqlite3/statement.rb
107
+ - lib/sqlite3/translator.rb
108
+ - lib/sqlite3/value.rb
109
+ - lib/sqlite3/version.rb
110
+ - setup.rb
111
+ - tasks/faq.rake
112
+ - tasks/gem.rake
113
+ - tasks/native.rake
114
+ - tasks/vendor_sqlite3.rake
115
+ - test/helper.rb
116
+ - test/test_backup.rb
117
+ - test/test_collation.rb
118
+ - test/test_database.rb
119
+ - test/test_database_readonly.rb
120
+ - test/test_deprecated.rb
121
+ - test/test_encoding.rb
122
+ - test/test_integration.rb
123
+ - test/test_integration_open_close.rb
124
+ - test/test_integration_pending.rb
125
+ - test/test_integration_resultset.rb
126
+ - test/test_integration_statement.rb
127
+ - test/test_sqlite3.rb
128
+ - test/test_statement.rb
129
+ - test/test_statement_execute.rb
130
+ - .gemtest
131
+ has_rdoc: true
132
+ homepage: http://github.com/luislavena/sqlite3-ruby
133
+ licenses: []
134
+
135
+ post_install_message:
136
+ rdoc_options:
137
+ - --main
138
+ - README.rdoc
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 57
147
+ segments:
148
+ - 1
149
+ - 8
150
+ - 7
151
+ version: 1.8.7
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 17
158
+ segments:
159
+ - 1
160
+ - 3
161
+ - 5
162
+ version: 1.3.5
163
+ requirements: []
164
+
165
+ rubyforge_project: dawanda-sqlite3
166
+ rubygems_version: 1.4.2
167
+ signing_key:
168
+ specification_version: 3
169
+ summary: This module allows Ruby programs to interface with the SQLite3 database engine (http://www.sqlite.org)
170
+ test_files:
171
+ - test/test_statement_execute.rb
172
+ - test/test_integration_resultset.rb
173
+ - test/test_database_readonly.rb
174
+ - test/test_database.rb
175
+ - test/test_encoding.rb
176
+ - test/test_integration_open_close.rb
177
+ - test/test_integration.rb
178
+ - test/test_sqlite3.rb
179
+ - test/test_collation.rb
180
+ - test/test_integration_pending.rb
181
+ - test/test_integration_statement.rb
182
+ - test/test_deprecated.rb
183
+ - test/test_backup.rb
184
+ - test/test_statement.rb