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