sqlite3 1.5.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +390 -0
- data/CONTRIBUTING.md +34 -2
- data/{faq/faq.md → FAQ.md} +0 -43
- data/INSTALLATION.md +269 -0
- data/LICENSE +18 -22
- data/README.md +76 -128
- data/dependencies.yml +13 -0
- data/ext/sqlite3/aggregator.c +142 -146
- data/ext/sqlite3/aggregator.h +2 -4
- data/ext/sqlite3/backup.c +86 -64
- data/ext/sqlite3/backup.h +2 -2
- data/ext/sqlite3/database.c +543 -465
- data/ext/sqlite3/database.h +9 -4
- data/ext/sqlite3/exception.c +111 -92
- data/ext/sqlite3/exception.h +3 -1
- data/ext/sqlite3/extconf.rb +83 -51
- data/ext/sqlite3/sqlite3.c +160 -115
- data/ext/sqlite3/sqlite3_ruby.h +2 -2
- data/ext/sqlite3/statement.c +518 -293
- data/ext/sqlite3/statement.h +3 -3
- data/ext/sqlite3/timespec.h +20 -0
- data/lib/sqlite3/constants.rb +171 -47
- data/lib/sqlite3/database.rb +141 -181
- data/lib/sqlite3/errors.rb +26 -1
- data/lib/sqlite3/pragmas.rb +128 -138
- data/lib/sqlite3/resultset.rb +14 -105
- data/lib/sqlite3/statement.rb +58 -13
- data/lib/sqlite3/value.rb +17 -20
- data/lib/sqlite3/version.rb +1 -21
- data/lib/sqlite3.rb +6 -4
- data/ports/archives/sqlite-autoconf-3460000.tar.gz +0 -0
- metadata +19 -107
- data/API_CHANGES.md +0 -49
- data/ChangeLog.cvs +0 -88
- data/Gemfile +0 -3
- data/LICENSE-DEPENDENCIES +0 -20
- data/faq/faq.rb +0 -145
- data/faq/faq.yml +0 -426
- data/lib/sqlite3/translator.rb +0 -118
- data/ports/archives/sqlite-autoconf-3380500.tar.gz +0 -0
- data/test/helper.rb +0 -27
- data/test/test_backup.rb +0 -33
- data/test/test_collation.rb +0 -82
- data/test/test_database.rb +0 -545
- data/test/test_database_flags.rb +0 -95
- data/test/test_database_readonly.rb +0 -36
- data/test/test_database_readwrite.rb +0 -41
- data/test/test_deprecated.rb +0 -44
- data/test/test_encoding.rb +0 -155
- data/test/test_integration.rb +0 -507
- data/test/test_integration_aggregate.rb +0 -336
- data/test/test_integration_open_close.rb +0 -30
- data/test/test_integration_pending.rb +0 -115
- data/test/test_integration_resultset.rb +0 -142
- data/test/test_integration_statement.rb +0 -194
- data/test/test_result_set.rb +0 -37
- data/test/test_sqlite3.rb +0 -30
- data/test/test_statement.rb +0 -263
- data/test/test_statement_execute.rb +0 -35
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module SQLite3
|
4
|
-
class TestDatabaseReadwrite < SQLite3::TestCase
|
5
|
-
def setup
|
6
|
-
File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db')
|
7
|
-
@db = SQLite3::Database.new('test-readwrite.db')
|
8
|
-
@db.execute("CREATE TABLE foos (id integer)")
|
9
|
-
@db.close
|
10
|
-
end
|
11
|
-
|
12
|
-
def teardown
|
13
|
-
@db.close unless @db.closed?
|
14
|
-
File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db')
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_open_readwrite_database
|
18
|
-
@db = SQLite3::Database.new('test-readwrite.db', :readwrite => true)
|
19
|
-
assert !@db.readonly?
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_open_readwrite_readonly_database
|
23
|
-
assert_raise(RuntimeError) do
|
24
|
-
@db = SQLite3::Database.new('test-readwrite.db', :readwrite => true, :readonly => true)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_open_readwrite_not_exists_database
|
29
|
-
File.unlink 'test-readwrite.db'
|
30
|
-
assert_raise(SQLite3::CantOpenException) do
|
31
|
-
@db = SQLite3::Database.new('test-readwrite.db', :readonly => true)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_insert_readwrite_database
|
36
|
-
@db = SQLite3::Database.new('test-readwrite.db', :readwrite => true)
|
37
|
-
@db.execute("INSERT INTO foos (id) VALUES (12)")
|
38
|
-
assert @db.changes == 1
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/test/test_deprecated.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module SQLite3
|
4
|
-
class TestDeprecated < SQLite3::TestCase
|
5
|
-
attr_reader :db
|
6
|
-
|
7
|
-
def setup
|
8
|
-
super
|
9
|
-
@warn_before = $-w
|
10
|
-
$-w = false
|
11
|
-
@db = SQLite3::Database.new(':memory:')
|
12
|
-
@db.execute 'CREATE TABLE test_table (name text, age int)'
|
13
|
-
end
|
14
|
-
|
15
|
-
def teardown
|
16
|
-
super
|
17
|
-
$-w = @warn_before
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_query_with_many_bind_params_not_nil
|
21
|
-
assert_equal [[1, 2]], db.query('select ?, ?', 1, 2).to_a
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_execute_with_many_bind_params_not_nil
|
25
|
-
assert_equal [[1, 2]], @db.execute("select ?, ?", 1, 2).to_a
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_query_with_many_bind_params
|
29
|
-
assert_equal [[nil, 1]], @db.query("select ?, ?", nil, 1).to_a
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_query_with_nil_bind_params
|
33
|
-
assert_equal [['foo']], @db.query("select 'foo'", nil).to_a
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_execute_with_many_bind_params
|
37
|
-
assert_equal [[nil, 1]], @db.execute("select ?, ?", nil, 1)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_execute_with_nil_bind_params
|
41
|
-
assert_equal [['foo']], @db.execute("select 'foo'", nil)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/test/test_encoding.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
module SQLite3
|
6
|
-
class TestEncoding < SQLite3::TestCase
|
7
|
-
def setup
|
8
|
-
@db = SQLite3::Database.new(':memory:')
|
9
|
-
@create = "create table ex(id int, data string)"
|
10
|
-
@insert = "insert into ex(id, data) values (?, ?)"
|
11
|
-
@db.execute(@create);
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_select_encoding_on_utf_16
|
15
|
-
str = "foo"
|
16
|
-
utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
|
17
|
-
db = SQLite3::Database.new(':memory:'.encode(utf16))
|
18
|
-
db.execute @create
|
19
|
-
db.execute "insert into ex (id, data) values (1, \"#{str}\")"
|
20
|
-
|
21
|
-
stmt = db.prepare 'select * from ex where data = ?'
|
22
|
-
['US-ASCII', utf16, 'EUC-JP', 'UTF-8'].each do |enc|
|
23
|
-
stmt.bind_param 1, str.encode(enc)
|
24
|
-
assert_equal 1, stmt.to_a.length
|
25
|
-
stmt.reset!
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_insert_encoding
|
30
|
-
str = "foo"
|
31
|
-
utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
|
32
|
-
db = SQLite3::Database.new(':memory:'.encode(utf16))
|
33
|
-
db.execute @create
|
34
|
-
stmt = db.prepare @insert
|
35
|
-
|
36
|
-
['US-ASCII', utf16, 'EUC-JP', 'UTF-8'].each_with_index do |enc,i|
|
37
|
-
stmt.bind_param 1, i
|
38
|
-
stmt.bind_param 2, str.encode(enc)
|
39
|
-
stmt.to_a
|
40
|
-
stmt.reset!
|
41
|
-
end
|
42
|
-
|
43
|
-
db.execute('select data from ex').flatten.each do |s|
|
44
|
-
assert_equal str, s
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_default_internal_is_honored
|
49
|
-
warn_before = $-w
|
50
|
-
$-w = false
|
51
|
-
|
52
|
-
before_enc = Encoding.default_internal
|
53
|
-
|
54
|
-
str = "壁に耳あり、障子に目あり"
|
55
|
-
stmt = @db.prepare('insert into ex(data) values (?)')
|
56
|
-
stmt.bind_param 1, str
|
57
|
-
stmt.step
|
58
|
-
|
59
|
-
Encoding.default_internal = 'EUC-JP'
|
60
|
-
string = @db.execute('select data from ex').first.first
|
61
|
-
|
62
|
-
assert_equal Encoding.default_internal, string.encoding
|
63
|
-
assert_equal str.encode('EUC-JP'), string
|
64
|
-
assert_equal str, string.encode(str.encoding)
|
65
|
-
ensure
|
66
|
-
Encoding.default_internal = before_enc
|
67
|
-
$-w = warn_before
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_blob_is_binary
|
71
|
-
str = "猫舌"
|
72
|
-
@db.execute('create table foo(data text)')
|
73
|
-
stmt = @db.prepare('insert into foo(data) values (?)')
|
74
|
-
stmt.bind_param(1, SQLite3::Blob.new(str))
|
75
|
-
stmt.step
|
76
|
-
|
77
|
-
string = @db.execute('select data from foo').first.first
|
78
|
-
assert_equal Encoding.find('ASCII-8BIT'), string.encoding
|
79
|
-
assert_equal str, string.force_encoding('UTF-8')
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_blob_is_ascii8bit
|
83
|
-
str = "猫舌"
|
84
|
-
@db.execute('create table foo(data text)')
|
85
|
-
stmt = @db.prepare('insert into foo(data) values (?)')
|
86
|
-
stmt.bind_param(1, str.dup.force_encoding("ASCII-8BIT"))
|
87
|
-
stmt.step
|
88
|
-
|
89
|
-
string = @db.execute('select data from foo').first.first
|
90
|
-
assert_equal Encoding.find('ASCII-8BIT'), string.encoding
|
91
|
-
assert_equal str, string.force_encoding('UTF-8')
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_blob_with_eucjp
|
95
|
-
str = "猫舌".encode("EUC-JP")
|
96
|
-
@db.execute('create table foo(data text)')
|
97
|
-
stmt = @db.prepare('insert into foo(data) values (?)')
|
98
|
-
stmt.bind_param(1, SQLite3::Blob.new(str))
|
99
|
-
stmt.step
|
100
|
-
|
101
|
-
string = @db.execute('select data from foo').first.first
|
102
|
-
assert_equal Encoding.find('ASCII-8BIT'), string.encoding
|
103
|
-
assert_equal str, string.force_encoding('EUC-JP')
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_db_with_eucjp
|
107
|
-
db = SQLite3::Database.new(':memory:'.encode('EUC-JP'))
|
108
|
-
assert_equal(Encoding.find('UTF-8'), db.encoding)
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_db_with_utf16
|
112
|
-
utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
|
113
|
-
|
114
|
-
db = SQLite3::Database.new(':memory:'.encode(utf16))
|
115
|
-
assert_equal(Encoding.find(utf16), db.encoding)
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_statement_eucjp
|
119
|
-
str = "猫舌"
|
120
|
-
@db.execute("insert into ex(data) values ('#{str}')".encode('EUC-JP'))
|
121
|
-
row = @db.execute("select data from ex")
|
122
|
-
assert_equal @db.encoding, row.first.first.encoding
|
123
|
-
assert_equal str, row.first.first
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_statement_utf8
|
127
|
-
str = "猫舌"
|
128
|
-
@db.execute("insert into ex(data) values ('#{str}')")
|
129
|
-
row = @db.execute("select data from ex")
|
130
|
-
assert_equal @db.encoding, row.first.first.encoding
|
131
|
-
assert_equal str, row.first.first
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_encoding
|
135
|
-
assert_equal Encoding.find("UTF-8"), @db.encoding
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_utf_8
|
139
|
-
str = "猫舌"
|
140
|
-
@db.execute(@insert, [10, str])
|
141
|
-
row = @db.execute("select data from ex")
|
142
|
-
assert_equal @db.encoding, row.first.first.encoding
|
143
|
-
assert_equal str, row.first.first
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_euc_jp
|
147
|
-
str = "猫舌".encode('EUC-JP')
|
148
|
-
@db.execute(@insert, [10, str])
|
149
|
-
row = @db.execute("select data from ex")
|
150
|
-
assert_equal @db.encoding, row.first.first.encoding
|
151
|
-
assert_equal str.encode('UTF-8'), row.first.first
|
152
|
-
end
|
153
|
-
|
154
|
-
end if RUBY_VERSION >= '1.9.1'
|
155
|
-
end
|