sqlite3 1.6.7-x86_64-darwin → 1.6.9-x86_64-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 +25 -0
- data/Gemfile +3 -4
- data/dependencies.yml +8 -9
- data/lib/sqlite3/2.7/sqlite3_native.bundle +0 -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/database.rb +39 -9
- data/lib/sqlite3/version.rb +2 -2
- data/test/test_database.rb +85 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4794a5634e98c4efb03ce30c6fe17719774101d5af78c9ecd2b243f07a249686
|
4
|
+
data.tar.gz: 1dace3b1967fc90422d8bd70411453a12e7c083c7656172fe9dca9abf202ddfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b03ab2e200b72666176046690ea58545315d29370b839db2078de4cd643f71bc615a4134d3d59ad07f09a21eac9eb9f2939aaa3f76283db42c80cb401f1eebd0
|
7
|
+
data.tar.gz: b15eee45083d0cd4ae434a51d7d87c3970bfdfd698e74066d0dc1d4c766d3bd597bbb98b5f1e0bdaea6d9686bffe38e8d616c3d5a3afd4025322d647ed792f2f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# sqlite3-ruby Changelog
|
2
2
|
|
3
|
+
## 1.6.9 / 2023-11-26
|
4
|
+
|
5
|
+
### Dependencies
|
6
|
+
|
7
|
+
- Vendored sqlite is update to [v3.44.2](https://sqlite.org/releaselog/3_44_2.html). @flavorjones
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- `Database.new` now accepts a `:default_transaction_mode` option (defaulting to `:deferred`), and `Database#transaction` no longer requires a transaction mode to be specified. This should allow higher-level adapters to more easily choose a transaction mode for a database connection. [#426] @masamitsu-murase
|
12
|
+
|
13
|
+
|
14
|
+
## 1.6.8 / 2023-11-01
|
15
|
+
|
16
|
+
### Dependencies
|
17
|
+
|
18
|
+
- Vendored sqlite is updated to [v3.44.0](https://sqlite.org/releaselog/3_44_0.html). @flavorjones
|
19
|
+
- rake-compiler-dock updated to v1.3.1 for precompiled native gems. @flavorjones
|
20
|
+
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- `SQLite3::Database.open` now returns the block result. Previously this returned the Database object. [#415] @toy
|
25
|
+
- Documentation improvement in `lib/sqlite3/database.rb`. [#421] @szTheory
|
26
|
+
|
27
|
+
|
3
28
|
## 1.6.7 / 2023-10-10
|
4
29
|
|
5
30
|
### Dependencies
|
data/Gemfile
CHANGED
@@ -4,8 +4,7 @@ gemspec
|
|
4
4
|
|
5
5
|
gem("minitest", "5.20.0")
|
6
6
|
gem("rake-compiler", "1.2.5")
|
7
|
-
gem("rake-compiler-dock", "1.3.
|
8
|
-
gem("rdoc", "6.
|
9
|
-
gem("psych", "5.1.0")
|
7
|
+
gem("rake-compiler-dock", "1.3.1")
|
8
|
+
gem("rdoc", "6.6.0")
|
10
9
|
|
11
|
-
gem("ruby_memcheck", "2.2.
|
10
|
+
gem("ruby_memcheck", "2.2.1") if Gem::Platform.local.os == "linux"
|
data/dependencies.yml
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
# TODO: stop using symbols here once we no longer support Ruby 2.7 and can rely on symbolize_names
|
2
2
|
:sqlite3:
|
3
3
|
# checksum verified by first checking the published sha3(256) checksum against https://sqlite.org/download.html:
|
4
|
-
#
|
4
|
+
# 6c427f0547e2f7babe636b748dd5d5a1f2f31601adadef7e2805e7d1f7171861
|
5
5
|
#
|
6
|
-
# $ sha3sum -a 256 ports/archives/sqlite-autoconf-
|
7
|
-
#
|
6
|
+
# $ sha3sum -a 256 ports/archives/sqlite-autoconf-3440200.tar.gz
|
7
|
+
# 6c427f0547e2f7babe636b748dd5d5a1f2f31601adadef7e2805e7d1f7171861 ports/archives/sqlite-autoconf-3440200.tar.gz
|
8
8
|
#
|
9
|
-
# $ sha256sum ports/archives/sqlite-autoconf-
|
10
|
-
#
|
11
|
-
|
12
|
-
:version: "3.43.2"
|
9
|
+
# $ sha256sum ports/archives/sqlite-autoconf-3440200.tar.gz
|
10
|
+
# 1c6719a148bc41cf0f2bbbe3926d7ce3f5ca09d878f1246fcc20767b175bb407 ports/archives/sqlite-autoconf-3440200.tar.gz
|
11
|
+
:version: "3.44.2"
|
13
12
|
:files:
|
14
|
-
- :url: "https://sqlite.org/2023/sqlite-autoconf-
|
15
|
-
:sha256: "
|
13
|
+
- :url: "https://sqlite.org/2023/sqlite-autoconf-3440200.tar.gz"
|
14
|
+
:sha256: "1c6719a148bc41cf0f2bbbe3926d7ce3f5ca09d878f1246fcc20767b175bb407"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/sqlite3/database.rb
CHANGED
@@ -18,7 +18,7 @@ module SQLite3
|
|
18
18
|
# end
|
19
19
|
# end
|
20
20
|
#
|
21
|
-
# It wraps the lower-level methods
|
21
|
+
# It wraps the lower-level methods provided by the selected driver, and
|
22
22
|
# includes the Pragmas module for access to various pragma convenience
|
23
23
|
# methods.
|
24
24
|
#
|
@@ -39,7 +39,22 @@ module SQLite3
|
|
39
39
|
|
40
40
|
class << self
|
41
41
|
|
42
|
-
|
42
|
+
# Without block works exactly as new.
|
43
|
+
# With block, like new closes the database at the end, but unlike new
|
44
|
+
# returns the result of the block instead of the database instance.
|
45
|
+
def open( *args )
|
46
|
+
database = new(*args)
|
47
|
+
|
48
|
+
if block_given?
|
49
|
+
begin
|
50
|
+
yield database
|
51
|
+
ensure
|
52
|
+
database.close
|
53
|
+
end
|
54
|
+
else
|
55
|
+
database
|
56
|
+
end
|
57
|
+
end
|
43
58
|
|
44
59
|
# Quotes the given string, making it safe to use in an SQL statement.
|
45
60
|
# It replaces all instances of the single-quote character with two
|
@@ -56,12 +71,23 @@ module SQLite3
|
|
56
71
|
|
57
72
|
# call-seq: SQLite3::Database.new(file, options = {})
|
58
73
|
#
|
59
|
-
# Create a new Database object that opens the given file.
|
60
|
-
#
|
74
|
+
# Create a new Database object that opens the given file.
|
75
|
+
#
|
76
|
+
# Supported permissions +options+:
|
77
|
+
# - the default mode is <tt>READWRITE | CREATE</tt>
|
78
|
+
# - +:readonly+: boolean (default false), true to set the mode to +READONLY+
|
79
|
+
# - +:readwrite+: boolean (default false), true to set the mode to +READWRITE+
|
80
|
+
# - +:flags+: set the mode to a combination of SQLite3::Constants::Open flags.
|
81
|
+
#
|
82
|
+
# Supported encoding +options+:
|
83
|
+
# - +:utf16+: boolean (default false), is the filename's encoding UTF-16 (only needed if the filename encoding is not UTF_16LE or BE)
|
84
|
+
#
|
85
|
+
# Other supported +options+:
|
86
|
+
# - +:strict+: boolean (default false), disallow the use of double-quoted string literals (see https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted)
|
87
|
+
# - +:results_as_hash+: boolean (default false), return rows as hashes instead of arrays
|
88
|
+
# - +:type_translation+: boolean (default false), enable type translation
|
89
|
+
# - +:default_transaction_mode+: one of +:deferred+ (default), +:immediate+, or +:exclusive+. If a mode is not specified in a call to #transaction, this will be the default transaction mode.
|
61
90
|
#
|
62
|
-
# By default, the new database will return result rows as arrays
|
63
|
-
# (#results_as_hash) and has type translation disabled (#type_translation=).
|
64
|
-
|
65
91
|
def initialize file, options = {}, zvfs = nil
|
66
92
|
mode = Constants::Open::READWRITE | Constants::Open::CREATE
|
67
93
|
|
@@ -104,6 +130,7 @@ module SQLite3
|
|
104
130
|
@type_translation = options[:type_translation]
|
105
131
|
@type_translator = make_type_translator @type_translation
|
106
132
|
@readonly = mode & Constants::Open::READONLY != 0
|
133
|
+
@default_transaction_mode = options[:default_transaction_mode] || :deferred
|
107
134
|
|
108
135
|
if block_given?
|
109
136
|
begin
|
@@ -607,8 +634,10 @@ module SQLite3
|
|
607
634
|
# by SQLite, so attempting to nest a transaction will result in a runtime
|
608
635
|
# exception.
|
609
636
|
#
|
610
|
-
# The +mode+ parameter may be either <tt>:deferred</tt
|
637
|
+
# The +mode+ parameter may be either <tt>:deferred</tt>,
|
611
638
|
# <tt>:immediate</tt>, or <tt>:exclusive</tt>.
|
639
|
+
# If `nil` is specified, the default transaction mode, which was
|
640
|
+
# passed to #initialize, is used.
|
612
641
|
#
|
613
642
|
# If a block is given, the database instance is yielded to it, and the
|
614
643
|
# transaction is committed when the block terminates. If the block
|
@@ -619,7 +648,8 @@ module SQLite3
|
|
619
648
|
# If a block is not given, it is the caller's responsibility to end the
|
620
649
|
# transaction explicitly, either by calling #commit, or by calling
|
621
650
|
# #rollback.
|
622
|
-
def transaction( mode =
|
651
|
+
def transaction( mode = nil )
|
652
|
+
mode = @default_transaction_mode if mode.nil?
|
623
653
|
execute "begin #{mode.to_s} transaction"
|
624
654
|
|
625
655
|
if block_given?
|
data/lib/sqlite3/version.rb
CHANGED
data/test/test_database.rb
CHANGED
@@ -198,11 +198,25 @@ module SQLite3
|
|
198
198
|
|
199
199
|
def test_new
|
200
200
|
db = SQLite3::Database.new(':memory:')
|
201
|
-
|
201
|
+
assert_instance_of(SQLite3::Database, db)
|
202
202
|
ensure
|
203
203
|
db.close if db
|
204
204
|
end
|
205
205
|
|
206
|
+
def test_open
|
207
|
+
db = SQLite3::Database.open(':memory:')
|
208
|
+
assert_instance_of(SQLite3::Database, db)
|
209
|
+
ensure
|
210
|
+
db.close if db
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_open_returns_block_result
|
214
|
+
result = SQLite3::Database.open(':memory:') do |db|
|
215
|
+
:foo
|
216
|
+
end
|
217
|
+
assert_equal :foo, result
|
218
|
+
end
|
219
|
+
|
206
220
|
def test_new_yields_self
|
207
221
|
thing = nil
|
208
222
|
SQLite3::Database.new(':memory:') do |db|
|
@@ -211,6 +225,14 @@ module SQLite3
|
|
211
225
|
assert_instance_of(SQLite3::Database, thing)
|
212
226
|
end
|
213
227
|
|
228
|
+
def test_open_yields_self
|
229
|
+
thing = nil
|
230
|
+
SQLite3::Database.open(':memory:') do |db|
|
231
|
+
thing = db
|
232
|
+
end
|
233
|
+
assert_instance_of(SQLite3::Database, thing)
|
234
|
+
end
|
235
|
+
|
214
236
|
def test_new_with_options
|
215
237
|
# determine if Ruby is running on Big Endian platform
|
216
238
|
utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
|
@@ -221,7 +243,7 @@ module SQLite3
|
|
221
243
|
db = SQLite3::Database.new(Iconv.conv(utf16, 'UTF-8', ':memory:'),
|
222
244
|
:utf16 => true)
|
223
245
|
end
|
224
|
-
|
246
|
+
assert_instance_of(SQLite3::Database, db)
|
225
247
|
ensure
|
226
248
|
db.close if db
|
227
249
|
end
|
@@ -241,6 +263,15 @@ module SQLite3
|
|
241
263
|
assert thing.closed?
|
242
264
|
end
|
243
265
|
|
266
|
+
def test_open_with_block_closes_self
|
267
|
+
thing = nil
|
268
|
+
SQLite3::Database.open(':memory:') do |db|
|
269
|
+
thing = db
|
270
|
+
assert !thing.closed?
|
271
|
+
end
|
272
|
+
assert thing.closed?
|
273
|
+
end
|
274
|
+
|
244
275
|
def test_block_closes_self_even_raised
|
245
276
|
thing = nil
|
246
277
|
begin
|
@@ -253,6 +284,18 @@ module SQLite3
|
|
253
284
|
assert thing.closed?
|
254
285
|
end
|
255
286
|
|
287
|
+
def test_open_with_block_closes_self_even_raised
|
288
|
+
thing = nil
|
289
|
+
begin
|
290
|
+
SQLite3::Database.open(':memory:') do |db|
|
291
|
+
thing = db
|
292
|
+
raise
|
293
|
+
end
|
294
|
+
rescue
|
295
|
+
end
|
296
|
+
assert thing.closed?
|
297
|
+
end
|
298
|
+
|
256
299
|
def test_prepare
|
257
300
|
db = SQLite3::Database.new(':memory:')
|
258
301
|
stmt = db.prepare('select "hello world"')
|
@@ -581,5 +624,45 @@ module SQLite3
|
|
581
624
|
db.execute("insert into foo values (?)", Float::INFINITY)
|
582
625
|
assert_equal Float::INFINITY, db.execute("select avg(temperature) from foo").first.first
|
583
626
|
end
|
627
|
+
|
628
|
+
def test_default_transaction_mode
|
629
|
+
tf = Tempfile.new 'database_default_transaction_mode'
|
630
|
+
SQLite3::Database.new(tf.path) do |db|
|
631
|
+
db.execute("create table foo (score int)")
|
632
|
+
db.execute("insert into foo values (?)", 1)
|
633
|
+
end
|
634
|
+
|
635
|
+
test_cases = [
|
636
|
+
{mode: nil, read: true, write: true},
|
637
|
+
{mode: :deferred, read: true, write: true},
|
638
|
+
{mode: :immediate, read: true, write: false},
|
639
|
+
{mode: :exclusive, read: false, write: false},
|
640
|
+
]
|
641
|
+
|
642
|
+
test_cases.each do |item|
|
643
|
+
db = SQLite3::Database.new tf.path, default_transaction_mode: item[:mode]
|
644
|
+
db2 = SQLite3::Database.new tf.path
|
645
|
+
db.transaction do
|
646
|
+
sql_for_read_test = "select * from foo"
|
647
|
+
if item[:read]
|
648
|
+
assert_nothing_raised{ db2.execute(sql_for_read_test) }
|
649
|
+
else
|
650
|
+
assert_raises(SQLite3::BusyException){ db2.execute(sql_for_read_test) }
|
651
|
+
end
|
652
|
+
|
653
|
+
sql_for_write_test = "insert into foo values (2)"
|
654
|
+
if item[:write]
|
655
|
+
assert_nothing_raised{ db2.execute(sql_for_write_test) }
|
656
|
+
else
|
657
|
+
assert_raises(SQLite3::BusyException){ db2.execute(sql_for_write_test) }
|
658
|
+
end
|
659
|
+
end
|
660
|
+
ensure
|
661
|
+
db.close if db && !db.closed?
|
662
|
+
db2.close if db2 && !db2.closed?
|
663
|
+
end
|
664
|
+
ensure
|
665
|
+
tf.unlink if tf
|
666
|
+
end
|
584
667
|
end
|
585
668
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlite3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.9
|
5
5
|
platform: x86_64-darwin
|
6
6
|
authors:
|
7
7
|
- Jamis Buck
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-
|
14
|
+
date: 2023-11-26 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: |
|
17
17
|
Ruby library to interface with the SQLite3 database engine (http://www.sqlite.org). Precompiled
|