sqlite3 1.7.3-arm64-darwin → 2.0.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +152 -0
- data/CONTRIBUTING.md +23 -1
- data/FAQ.md +0 -43
- data/INSTALLATION.md +13 -5
- data/LICENSE +18 -22
- data/README.md +75 -4
- data/dependencies.yml +10 -11
- data/ext/sqlite3/aggregator.c +142 -145
- data/ext/sqlite3/aggregator.h +2 -4
- data/ext/sqlite3/backup.c +74 -65
- data/ext/sqlite3/backup.h +2 -2
- data/ext/sqlite3/database.c +535 -482
- data/ext/sqlite3/database.h +7 -4
- data/ext/sqlite3/exception.c +111 -92
- data/ext/sqlite3/exception.h +3 -1
- data/ext/sqlite3/extconf.rb +21 -22
- data/ext/sqlite3/sqlite3.c +159 -115
- data/ext/sqlite3/sqlite3_ruby.h +2 -2
- data/ext/sqlite3/statement.c +516 -300
- data/ext/sqlite3/statement.h +3 -3
- data/ext/sqlite3/timespec.h +20 -0
- data/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
- data/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
- data/lib/sqlite3/3.2/sqlite3_native.bundle +0 -0
- data/lib/sqlite3/3.3/sqlite3_native.bundle +0 -0
- data/lib/sqlite3/constants.rb +171 -47
- data/lib/sqlite3/database.rb +105 -165
- data/lib/sqlite3/errors.rb +26 -1
- data/lib/sqlite3/pragmas.rb +126 -136
- data/lib/sqlite3/resultset.rb +14 -97
- 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
- metadata +3 -28
- data/API_CHANGES.md +0 -49
- data/ChangeLog.cvs +0 -88
- data/Gemfile +0 -10
- data/LICENSE-DEPENDENCIES +0 -20
- data/lib/sqlite3/translator.rb +0 -117
- 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 -668
- 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 -49
- data/test/test_encoding.rb +0 -165
- 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_pragmas.rb +0 -22
- data/test/test_result_set.rb +0 -47
- data/test/test_sqlite3.rb +0 -30
- data/test/test_statement.rb +0 -290
- data/test/test_statement_execute.rb +0 -39
data/test/test_database_flags.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module SQLite3
|
4
|
-
class TestDatabaseFlags < SQLite3::TestCase
|
5
|
-
def setup
|
6
|
-
File.unlink 'test-flags.db' if File.exist?('test-flags.db')
|
7
|
-
@db = SQLite3::Database.new('test-flags.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-flags.db' if File.exist?('test-flags.db')
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_open_database_flags_constants
|
18
|
-
defined_to_date = [:READONLY, :READWRITE, :CREATE, :DELETEONCLOSE,
|
19
|
-
:EXCLUSIVE, :MAIN_DB, :TEMP_DB, :TRANSIENT_DB,
|
20
|
-
:MAIN_JOURNAL, :TEMP_JOURNAL, :SUBJOURNAL,
|
21
|
-
:MASTER_JOURNAL, :NOMUTEX, :FULLMUTEX]
|
22
|
-
if SQLite3::SQLITE_VERSION_NUMBER > 3007002
|
23
|
-
defined_to_date += [:AUTOPROXY, :SHAREDCACHE, :PRIVATECACHE, :WAL]
|
24
|
-
end
|
25
|
-
if SQLite3::SQLITE_VERSION_NUMBER > 3007007
|
26
|
-
defined_to_date += [:URI]
|
27
|
-
end
|
28
|
-
if SQLite3::SQLITE_VERSION_NUMBER > 3007013
|
29
|
-
defined_to_date += [:MEMORY]
|
30
|
-
end
|
31
|
-
assert defined_to_date.sort == SQLite3::Constants::Open.constants.sort
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_open_database_flags_conflicts_with_readonly
|
35
|
-
assert_raise(RuntimeError) do
|
36
|
-
@db = SQLite3::Database.new('test-flags.db', :flags => 2, :readonly => true)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_open_database_flags_conflicts_with_readwrite
|
41
|
-
assert_raise(RuntimeError) do
|
42
|
-
@db = SQLite3::Database.new('test-flags.db', :flags => 2, :readwrite => true)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_open_database_readonly_flags
|
47
|
-
@db = SQLite3::Database.new('test-flags.db', :flags => SQLite3::Constants::Open::READONLY)
|
48
|
-
assert @db.readonly?
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_open_database_readwrite_flags
|
52
|
-
@db = SQLite3::Database.new('test-flags.db', :flags => SQLite3::Constants::Open::READWRITE)
|
53
|
-
assert !@db.readonly?
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_open_database_readonly_flags_cant_open
|
57
|
-
File.unlink 'test-flags.db'
|
58
|
-
assert_raise(SQLite3::CantOpenException) do
|
59
|
-
@db = SQLite3::Database.new('test-flags.db', :flags => SQLite3::Constants::Open::READONLY)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_open_database_readwrite_flags_cant_open
|
64
|
-
File.unlink 'test-flags.db'
|
65
|
-
assert_raise(SQLite3::CantOpenException) do
|
66
|
-
@db = SQLite3::Database.new('test-flags.db', :flags => SQLite3::Constants::Open::READWRITE)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_open_database_misuse_flags
|
71
|
-
assert_raise(SQLite3::MisuseException) do
|
72
|
-
flags = SQLite3::Constants::Open::READONLY | SQLite3::Constants::Open::READWRITE # <== incompatible flags
|
73
|
-
@db = SQLite3::Database.new('test-flags.db', :flags => flags)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_open_database_create_flags
|
78
|
-
File.unlink 'test-flags.db'
|
79
|
-
flags = SQLite3::Constants::Open::READWRITE | SQLite3::Constants::Open::CREATE
|
80
|
-
@db = SQLite3::Database.new('test-flags.db', :flags => flags) do |db|
|
81
|
-
db.execute("CREATE TABLE foos (id integer)")
|
82
|
-
db.execute("INSERT INTO foos (id) VALUES (12)")
|
83
|
-
end
|
84
|
-
assert File.exist?('test-flags.db')
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_open_database_exotic_flags
|
88
|
-
flags = SQLite3::Constants::Open::READWRITE | SQLite3::Constants::Open::CREATE
|
89
|
-
exotic_flags = SQLite3::Constants::Open::NOMUTEX | SQLite3::Constants::Open::TEMP_DB
|
90
|
-
@db = SQLite3::Database.new('test-flags.db', :flags => flags | exotic_flags)
|
91
|
-
@db.execute("INSERT INTO foos (id) VALUES (12)")
|
92
|
-
assert @db.changes == 1
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module SQLite3
|
4
|
-
class TestDatabaseReadonly < SQLite3::TestCase
|
5
|
-
def setup
|
6
|
-
File.unlink 'test-readonly.db' if File.exist?('test-readonly.db')
|
7
|
-
@db = SQLite3::Database.new('test-readonly.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-readonly.db' if File.exist?('test-readonly.db')
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_open_readonly_database
|
18
|
-
@db = SQLite3::Database.new('test-readonly.db', :readonly => true)
|
19
|
-
assert @db.readonly?
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_open_readonly_not_exists_database
|
23
|
-
File.unlink 'test-readonly.db'
|
24
|
-
assert_raise(SQLite3::CantOpenException) do
|
25
|
-
@db = SQLite3::Database.new('test-readonly.db', :readonly => true)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_insert_readonly_database
|
30
|
-
@db = SQLite3::Database.new('test-readonly.db', :readonly => true)
|
31
|
-
assert_raise(SQLite3::ReadOnlyException) do
|
32
|
-
@db.execute("INSERT INTO foos (id) VALUES (12)")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -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,49 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module SQLite3
|
4
|
-
class TestDeprecated < SQLite3::TestCase
|
5
|
-
def setup
|
6
|
-
super
|
7
|
-
@warn_before = $-w
|
8
|
-
$-w = false
|
9
|
-
@db = SQLite3::Database.new(':memory:')
|
10
|
-
@db.execute 'CREATE TABLE test_table (name text, age int)'
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
super
|
15
|
-
$-w = @warn_before
|
16
|
-
@db.close
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_query_with_many_bind_params_not_nil
|
20
|
-
rs = @db.query('select ?, ?', 1, 2)
|
21
|
-
assert_equal [[1, 2]], rs.to_a
|
22
|
-
rs.close
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_execute_with_many_bind_params_not_nil
|
26
|
-
assert_equal [[1, 2]], @db.execute("select ?, ?", 1, 2).to_a
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_query_with_many_bind_params
|
30
|
-
rs = @db.query("select ?, ?", nil, 1)
|
31
|
-
assert_equal [[nil, 1]], rs.to_a
|
32
|
-
rs.close
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_query_with_nil_bind_params
|
36
|
-
rs = @db.query("select 'foo'", nil)
|
37
|
-
assert_equal [['foo']], rs.to_a
|
38
|
-
rs.close
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_execute_with_many_bind_params
|
42
|
-
assert_equal [[nil, 1]], @db.execute("select ?, ?", nil, 1)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_execute_with_nil_bind_params
|
46
|
-
assert_equal [['foo']], @db.execute("select 'foo'", nil)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/test/test_encoding.rb
DELETED
@@ -1,165 +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 teardown
|
15
|
-
@db.close
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_select_encoding_on_utf_16
|
19
|
-
str = "foo"
|
20
|
-
utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
|
21
|
-
db = SQLite3::Database.new(':memory:'.encode(utf16))
|
22
|
-
db.execute @create
|
23
|
-
db.execute "insert into ex (id, data) values (1, \"#{str}\")"
|
24
|
-
|
25
|
-
stmt = db.prepare 'select * from ex where data = ?'
|
26
|
-
['US-ASCII', utf16, 'EUC-JP', 'UTF-8'].each do |enc|
|
27
|
-
stmt.bind_param 1, str.encode(enc)
|
28
|
-
assert_equal 1, stmt.to_a.length
|
29
|
-
stmt.reset!
|
30
|
-
end
|
31
|
-
stmt.close
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_insert_encoding
|
35
|
-
str = "foo"
|
36
|
-
utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
|
37
|
-
db = SQLite3::Database.new(':memory:'.encode(utf16))
|
38
|
-
db.execute @create
|
39
|
-
stmt = db.prepare @insert
|
40
|
-
|
41
|
-
['US-ASCII', utf16, 'EUC-JP', 'UTF-8'].each_with_index do |enc,i|
|
42
|
-
stmt.bind_param 1, i
|
43
|
-
stmt.bind_param 2, str.encode(enc)
|
44
|
-
stmt.to_a
|
45
|
-
stmt.reset!
|
46
|
-
end
|
47
|
-
stmt.close
|
48
|
-
|
49
|
-
db.execute('select data from ex').flatten.each do |s|
|
50
|
-
assert_equal str, s
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_default_internal_is_honored
|
55
|
-
warn_before = $-w
|
56
|
-
$-w = false
|
57
|
-
|
58
|
-
before_enc = Encoding.default_internal
|
59
|
-
|
60
|
-
str = "壁に耳あり、障子に目あり"
|
61
|
-
stmt = @db.prepare('insert into ex(data) values (?)')
|
62
|
-
stmt.bind_param 1, str
|
63
|
-
stmt.step
|
64
|
-
stmt.close
|
65
|
-
|
66
|
-
Encoding.default_internal = 'EUC-JP'
|
67
|
-
string = @db.execute('select data from ex').first.first
|
68
|
-
|
69
|
-
assert_equal Encoding.default_internal, string.encoding
|
70
|
-
assert_equal str.encode('EUC-JP'), string
|
71
|
-
assert_equal str, string.encode(str.encoding)
|
72
|
-
ensure
|
73
|
-
Encoding.default_internal = before_enc
|
74
|
-
$-w = warn_before
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_blob_is_binary
|
78
|
-
str = "猫舌"
|
79
|
-
@db.execute('create table foo(data text)')
|
80
|
-
stmt = @db.prepare('insert into foo(data) values (?)')
|
81
|
-
stmt.bind_param(1, SQLite3::Blob.new(str))
|
82
|
-
stmt.step
|
83
|
-
stmt.close
|
84
|
-
|
85
|
-
string = @db.execute('select data from foo').first.first
|
86
|
-
assert_equal Encoding.find('ASCII-8BIT'), string.encoding
|
87
|
-
assert_equal str, string.force_encoding('UTF-8')
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_blob_is_ascii8bit
|
91
|
-
str = "猫舌"
|
92
|
-
@db.execute('create table foo(data text)')
|
93
|
-
stmt = @db.prepare('insert into foo(data) values (?)')
|
94
|
-
stmt.bind_param(1, str.dup.force_encoding("ASCII-8BIT"))
|
95
|
-
stmt.step
|
96
|
-
stmt.close
|
97
|
-
|
98
|
-
string = @db.execute('select data from foo').first.first
|
99
|
-
assert_equal Encoding.find('ASCII-8BIT'), string.encoding
|
100
|
-
assert_equal str, string.force_encoding('UTF-8')
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_blob_with_eucjp
|
104
|
-
str = "猫舌".encode("EUC-JP")
|
105
|
-
@db.execute('create table foo(data text)')
|
106
|
-
stmt = @db.prepare('insert into foo(data) values (?)')
|
107
|
-
stmt.bind_param(1, SQLite3::Blob.new(str))
|
108
|
-
stmt.step
|
109
|
-
stmt.close
|
110
|
-
|
111
|
-
string = @db.execute('select data from foo').first.first
|
112
|
-
assert_equal Encoding.find('ASCII-8BIT'), string.encoding
|
113
|
-
assert_equal str, string.force_encoding('EUC-JP')
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_db_with_eucjp
|
117
|
-
db = SQLite3::Database.new(':memory:'.encode('EUC-JP'))
|
118
|
-
assert_equal(Encoding.find('UTF-8'), db.encoding)
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_db_with_utf16
|
122
|
-
utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
|
123
|
-
|
124
|
-
db = SQLite3::Database.new(':memory:'.encode(utf16))
|
125
|
-
assert_equal(Encoding.find(utf16), db.encoding)
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_statement_eucjp
|
129
|
-
str = "猫舌"
|
130
|
-
@db.execute("insert into ex(data) values ('#{str}')".encode('EUC-JP'))
|
131
|
-
row = @db.execute("select data from ex")
|
132
|
-
assert_equal @db.encoding, row.first.first.encoding
|
133
|
-
assert_equal str, row.first.first
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_statement_utf8
|
137
|
-
str = "猫舌"
|
138
|
-
@db.execute("insert into ex(data) values ('#{str}')")
|
139
|
-
row = @db.execute("select data from ex")
|
140
|
-
assert_equal @db.encoding, row.first.first.encoding
|
141
|
-
assert_equal str, row.first.first
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_encoding
|
145
|
-
assert_equal Encoding.find("UTF-8"), @db.encoding
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_utf_8
|
149
|
-
str = "猫舌"
|
150
|
-
@db.execute(@insert, [10, str])
|
151
|
-
row = @db.execute("select data from ex")
|
152
|
-
assert_equal @db.encoding, row.first.first.encoding
|
153
|
-
assert_equal str, row.first.first
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_euc_jp
|
157
|
-
str = "猫舌".encode('EUC-JP')
|
158
|
-
@db.execute(@insert, [10, str])
|
159
|
-
row = @db.execute("select data from ex")
|
160
|
-
assert_equal @db.encoding, row.first.first.encoding
|
161
|
-
assert_equal str.encode('UTF-8'), row.first.first
|
162
|
-
end
|
163
|
-
|
164
|
-
end if RUBY_VERSION >= '1.9.1'
|
165
|
-
end
|