sqlite3 1.7.3-aarch64-linux → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +363 -1
- data/CONTRIBUTING.md +33 -7
- data/FAQ.md +52 -84
- data/INSTALLATION.md +21 -13
- data/LICENSE +18 -22
- data/README.md +97 -9
- data/dependencies.yml +10 -11
- data/ext/sqlite3/aggregator.c +143 -146
- 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 +623 -495
- data/ext/sqlite3/database.h +13 -4
- data/ext/sqlite3/exception.c +116 -92
- data/ext/sqlite3/exception.h +5 -1
- data/ext/sqlite3/extconf.rb +36 -24
- data/ext/sqlite3/sqlite3.c +176 -115
- data/ext/sqlite3/sqlite3_ruby.h +2 -2
- data/ext/sqlite3/statement.c +588 -300
- data/ext/sqlite3/statement.h +4 -3
- data/ext/sqlite3/timespec.h +20 -0
- data/lib/sqlite3/constants.rb +195 -47
- data/lib/sqlite3/database.rb +224 -187
- data/lib/sqlite3/errors.rb +54 -1
- data/lib/sqlite3/fork_safety.rb +66 -0
- data/lib/sqlite3/pragmas.rb +194 -141
- 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 +2 -21
- data/lib/sqlite3/version_info.rb +17 -0
- data/lib/sqlite3.rb +8 -4
- data/ports/archives/sqlite-autoconf-3510100.tar.gz +0 -0
- metadata +28 -45
- data/API_CHANGES.md +0 -49
- data/ChangeLog.cvs +0 -88
- data/Gemfile +0 -10
- data/LICENSE-DEPENDENCIES +0 -20
- data/lib/sqlite3/3.0/sqlite3_native.so +0 -0
- data/lib/sqlite3/3.1/sqlite3_native.so +0 -0
- data/lib/sqlite3/3.2/sqlite3_native.so +0 -0
- data/lib/sqlite3/3.3/sqlite3_native.so +0 -0
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f6be69cc8ecc49c2f73e5e4d930539f388f1dbda5f9cd3929a9acac0322dbb1
|
|
4
|
+
data.tar.gz: c64e0c37d6520ea642ccaae988b5c415549a74235e421bdd8dd4bb1da9f77c2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 723573544ea828a3cdc493fada6970740f41cc188abd3ca5bcc7c5ed25efcaab0f02e45531c212d0491f9cfcf9e628013db34e4bdcba23b9ddd4f1f6f024127b
|
|
7
|
+
data.tar.gz: 3d9f66847cdbfbdf5ed5e68fd8878baaf42ba7683e396357a2fc9e5bc3bdabea12f5bebf6d1f9cf55dc0fd114b64f0b8cc90431253398e2d63d5d7547004bca8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,367 @@
|
|
|
1
1
|
# sqlite3-ruby Changelog
|
|
2
2
|
|
|
3
|
+
## 2.9.0 / 2025-12-27
|
|
4
|
+
|
|
5
|
+
### Ruby
|
|
6
|
+
|
|
7
|
+
- Introduce native gem packages for Ruby 4.0. @flavorjones
|
|
8
|
+
- Drop support for Ruby 3.1. @flavorjones
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Introduce `Statement#named_params` to introspect on a parameterized SQL statement. #627 #642 @captn3m0
|
|
13
|
+
|
|
14
|
+
### Improved
|
|
15
|
+
|
|
16
|
+
- Small improvements to docstrings and comments. @flavorjones @houyuanjie
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## 2.8.1 / 2025-11-29
|
|
20
|
+
|
|
21
|
+
- Vendored sqlite is updated to [v3.51.1](https://www.sqlite.org/releaselog/3_51_1.html) (from v3.51.0). #659 @flavorjones
|
|
22
|
+
- Precompiled native gems are built with rake-compiler-dock v1.10.0 (previously v1.9.1).
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## 2.8.0 / 2025-11-05
|
|
26
|
+
|
|
27
|
+
- Vendored sqlite is updated to [v3.51.0](https://www.sqlite.org/releaselog/3_51_0.html) (from v3.50.4). #652 @flavorjones
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 2.7.4 / 2025-09-19
|
|
31
|
+
|
|
32
|
+
- Vendored sqlite is updated to [v3.50.4](https://www.sqlite.org/releaselog/3_50_4.html) (from v3.50.3). #644 @flavorjones
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## 2.7.3 / 2025-07-18
|
|
36
|
+
|
|
37
|
+
- Vendored sqlite is updated to [v3.50.3](https://sqlite.org/releaselog/3_50_3.html) (from v3.50.2). #638 @flavorjones
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## 2.7.2 / 2025-07-05
|
|
41
|
+
|
|
42
|
+
- Backport a [fix](https://sqlite.org/src/info/64f5f14322) to the vendored SQLite to support compilation on Rocky Linux. See the [SQLite forum post](https://sqlite.org/forum/forumpost/44a58c8073) for more details. #634, #635 @flavorjones
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## 2.7.1 / 2025-06-30
|
|
46
|
+
|
|
47
|
+
- Vendored sqlite is updated to [v3.50.2](https://sqlite.org/releaselog/3_50_2.html) (from v3.50.1). #633 @flavorjones
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## 2.7.0 / 2025-06-09
|
|
51
|
+
|
|
52
|
+
- Vendored sqlite is updated to [v3.50.1](https://sqlite.org/releaselog/3_50_1.html) (from v3.49.1). #630 @flavorjones
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## 2.6.0 / 2025-02-20
|
|
56
|
+
|
|
57
|
+
### Dependencies
|
|
58
|
+
|
|
59
|
+
- Vendored sqlite is updated to [v3.49.1](https://sqlite.org/releaselog/3_49_1.html) (from v3.47.2). #605 @flavorjones
|
|
60
|
+
- Updated to rake-compiler-dock v1.9.1. #610 @flavorjones
|
|
61
|
+
|
|
62
|
+
### Important note for Window users
|
|
63
|
+
|
|
64
|
+
Loading extensions is not available on Windows when using the precompiled native gems or compiling the vendored sqlite library from source, starting with sqlite3-ruby v2.6.0.
|
|
65
|
+
|
|
66
|
+
Sqlite 3.48.0 and later have dramatically changed the "autoconf amalgamation" that is vendored in this gem. Specifically, the configuration is no longer actually autoconf, but some scripts that emulate autoconf's interface and behavior.
|
|
67
|
+
|
|
68
|
+
Although this _mostly_ "just worked", we're having a problem resolving the libraries necessary for loading extensions. As a result, starting with sqlite3-ruby v2.6.0, extensions cannot be loaded on Windows when using precompiled native gems or when compiling the vendored sqlite library.
|
|
69
|
+
|
|
70
|
+
If you are willing and able to help fix this, let us know at https://github.com/sparklemotion/sqlite3-ruby/issues/618.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## 2.5.0 / 2024-12-25
|
|
74
|
+
|
|
75
|
+
### Ruby
|
|
76
|
+
|
|
77
|
+
This release introduces native gem packages that include Ruby 3.4.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## 2.4.1 / 2024-12-08
|
|
81
|
+
|
|
82
|
+
### Dependencies
|
|
83
|
+
|
|
84
|
+
- Vendored sqlite is updated to [v3.47.2](https://sqlite.org/releaselog/3_47.2.html) #593 @flavorjones
|
|
85
|
+
|
|
86
|
+
The description from the upstream maintainers is:
|
|
87
|
+
|
|
88
|
+
> SQLite version 3.47.2, now available, fixes an important bug that first appeared in the 3.47.0
|
|
89
|
+
> release. In SQLite versions 3.47.0 and 3.47.1, if you try to convert a string into a
|
|
90
|
+
> floating-point value and the first 16 significant digits of the value are exactly
|
|
91
|
+
> "1844674407370955", then the floating-point number generated might be incorrect. The problem
|
|
92
|
+
> only affects x64 and i386 CPUs, so it does not affect you if you are running on ARM. And it only
|
|
93
|
+
> affects releases 3.47.0 and 3.47.1. **If you are running SQLite versions 3.47.0 or 3.47.1, then
|
|
94
|
+
> upgrading is recommended.**
|
|
95
|
+
|
|
96
|
+
Saving you a click, you should upgrade if you're running sqlite3-ruby v2.1.1 or later.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Fixed
|
|
100
|
+
|
|
101
|
+
- Prevent unnecessary "Invalid Reference" warnings from the `ForkSafety` module when GC runs during the "after fork" hook. #592 @flavorjones
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## 2.4.0 / 2024-12-03
|
|
105
|
+
|
|
106
|
+
### Added
|
|
107
|
+
|
|
108
|
+
- `Database#load_extension` now accepts any object that responds to `#to_path`, in addition to String filesystem paths. [#586] @flavorjones
|
|
109
|
+
- `Database.new` now accepts an `extensions:` parameter, which is an array of SQLite extensions that will be loaded during initialization. The array may contain String filesystem paths and objects that respond to `#to_path`. [#586] @flavorjones
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
## 2.3.1 / 2024-11-25
|
|
113
|
+
|
|
114
|
+
### Dependencies
|
|
115
|
+
|
|
116
|
+
- Vendored sqlite is updated to [v3.47.1](https://sqlite.org/releaselog/3_47_1.html) [#589] @flavorjones
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
## 2.3.0 / 2024-11-20
|
|
120
|
+
|
|
121
|
+
### Added
|
|
122
|
+
|
|
123
|
+
- The SQLITE_DBPAGE extension is now enabled by default, which implements an eponymous-only virtual table that provides direct access to the underlying database file by interacting with the pager. See https://www.sqlite.org/dbpage.html for more information. [#578] @flavorjones
|
|
124
|
+
- The DBSTAT extension is now enabled by default, which implements a read-only eponymous virtual table that returns information about the amount of disk space used to store the content of an SQLite database. See https://sqlite.org/dbstat.html for more information. [#580] @pawurb @flavorjones
|
|
125
|
+
- `Database#optimize` which wraps the `pragma optimize;` statement. Also added `Constants::Optimize` to allow advanced users to pass a bitmask of options. See https://www.sqlite.org/pragma.html#pragma_optimize. [#572] @alexcwatt @flavorjones
|
|
126
|
+
- `SQLite3::VERSION_INFO` is contains a bag of metadata about the gem and the sqlite library used. `SQLite3::SQLITE_PACKAGED_LIBRARIES` and `SQLite3::SQLITE_PRECOMPILED_LIBRARIES` are indicate how the gem was built. [#581] @flavorjones
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
### Fixed
|
|
130
|
+
|
|
131
|
+
- `Database#encoding=` support for switching the database encoding to `UTF-16BE`, which has been broken since `Database#encoding=` was introduced in v1.3.12 in 2016. [#575] @miyucy
|
|
132
|
+
- Omit mention of the `pkg-config` gem when failing to build from source, since it is not used. [#358] @flavorjones
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
## 2.2.0 / 2024-10-30
|
|
136
|
+
|
|
137
|
+
### Added
|
|
138
|
+
|
|
139
|
+
- URI filenames are now allowed. This allows the injection of some behavior via recognized query parameters. See https://www.sqlite.org/uri.html for more information. [#571] @flavorjones
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
### Improved
|
|
143
|
+
|
|
144
|
+
- SQL Syntax errors during `Database#prepare` will raise a verbose exception with a multiline message indicating with a "^" exactly where in the statement the error occurred. [#554] @fractaledmind @flavorjones
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
## 2.1.1 / 2024-10-22
|
|
148
|
+
|
|
149
|
+
### Dependencies
|
|
150
|
+
|
|
151
|
+
- Vendored sqlite is updated to [v3.47.0](https://sqlite.org/releaselog/3_47_0.html) [#570] @flavorjones
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
## 2.1.0 / 2024-09-24
|
|
155
|
+
|
|
156
|
+
### Ruby
|
|
157
|
+
|
|
158
|
+
- This release drops support for Ruby 3.0. [#563] @flavorjones
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### Fork safety improvements
|
|
162
|
+
|
|
163
|
+
Sqlite itself is [not fork-safe](https://www.sqlite.org/howtocorrupt.html#_carrying_an_open_database_connection_across_a_fork_). Specifically, writing in a child process to a database connection that was created in the parent process may corrupt the database file. To mitigate this risk, sqlite3-ruby has implemented the following changes:
|
|
164
|
+
|
|
165
|
+
- All open writable database connections carried across a `fork()` will immediately be closed in the child process to mitigate the risk of corrupting the database file.
|
|
166
|
+
- These connections will be incompletely closed ("discarded") which will result in a one-time memory leak in the child process.
|
|
167
|
+
|
|
168
|
+
If it's at all possible, we strongly recommend that you close writable database connections in the parent before forking. If absolutely necessary (and you know what you're doing), you may suppress the fork safety warnings by calling `SQLite3::ForkSafety.suppress_warnings!`.
|
|
169
|
+
|
|
170
|
+
See the README's "Fork Safety" section and `adr/2024-09-fork-safety.md` for more information. [#558, #565, #566] @flavorjones
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
### Improved
|
|
174
|
+
|
|
175
|
+
- Use `sqlite3_close_v2` to close databases in a deferred manner if there are unclosed prepared statements. Previously closing a database while statements were open resulted in a `BusyException`. See https://www.sqlite.org/c3ref/close.html for more context. [#557] @flavorjones
|
|
176
|
+
- When setting a Database `busy_handler`, fire the write barrier to prevent potential crashes during the GC mark phase. [#556] @jhawthorn
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
### Documentation
|
|
180
|
+
|
|
181
|
+
- The `FAQ.md` has been updated to fix some inaccuracies. [#562] @rickhull
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
## 2.0.4 / 2024-08-13
|
|
185
|
+
|
|
186
|
+
### Dependencies
|
|
187
|
+
|
|
188
|
+
- Vendored sqlite is updated to [v3.46.1](https://sqlite.org/releaselog/3_46_1.html) @flavorjones
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
## 2.0.3 / 2024-07-29
|
|
192
|
+
|
|
193
|
+
### Improved
|
|
194
|
+
|
|
195
|
+
- `Database#quote` avoids allocating strings where reusing frozen strings is preferable. #548 @casperisfine
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
## 2.0.2 / 2024-05-23
|
|
199
|
+
|
|
200
|
+
### Dependencies
|
|
201
|
+
|
|
202
|
+
- Vendored sqlite is updated to [v3.46.0](https://sqlite.org/releaselog/3_46_0.html) @flavorjones
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
## 2.0.1 / 2024-04-20
|
|
206
|
+
|
|
207
|
+
### Fixed
|
|
208
|
+
|
|
209
|
+
- Raise `ArgumentError` if `Database#execute`, `#execute_batch`, or `#query` are passed multiple bind parameters that are not in an Array. In v2.0.0 these methods would silently swallow additional arguments, and this change makes the failure explicit. See the CHANGELOG notes for v2.0.0 for examples on how to update your code. [#527] @flavorjones
|
|
210
|
+
- Fixed a regression in v2.0.0 that caused `Database#execute_batch` to raise an encoding exception when passed some non-ascii strings. As a result of this fix, `Database#prepare` now ensures the "remainder" string will always be encoded as UTF-8. [#524] @flavorjones
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
## 2.0.0 / 2024-04-17
|
|
214
|
+
|
|
215
|
+
This is a major release which contains some breaking changes, primarily the removal of
|
|
216
|
+
long-deprecated functionality. Before upgrading, please make sure to address deprecation warnings
|
|
217
|
+
emitted from your application using sqlite3-ruby v1.7.x.
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
### Ruby
|
|
221
|
+
|
|
222
|
+
- This release drops support for Ruby 2.7. [#453] @flavorjones
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
### Packaging
|
|
226
|
+
|
|
227
|
+
Native (precompiled) gems are now available for Linux Musl. [#442] @flavorjones
|
|
228
|
+
|
|
229
|
+
Here are the platforms for which native gems are shipped:
|
|
230
|
+
|
|
231
|
+
- `aarch64-linux-gnu` (requires: glibc >= 2.29)
|
|
232
|
+
- `aarch64-linux-musl`
|
|
233
|
+
- `arm-linux-gnu` (requires: glibc >= 2.29)
|
|
234
|
+
- `arm-linux-musl`
|
|
235
|
+
- `arm64-darwin`
|
|
236
|
+
- `x64-mingw32` / `x64-mingw-ucrt`
|
|
237
|
+
- `x86-linux-gnu` (requires: glibc >= 2.17)
|
|
238
|
+
- `x86-linux-musl`
|
|
239
|
+
- `x86_64-darwin`
|
|
240
|
+
- `x86_64-linux-gnu` (requires: glibc >= 2.17)
|
|
241
|
+
- `x86_64-linux-musl`
|
|
242
|
+
|
|
243
|
+
⚠ Ruby 3.0 linux users must use Rubygems >= 3.3.22 in order to use these gems.
|
|
244
|
+
|
|
245
|
+
⚠ Musl linux users should update to Bundler >= 2.5.6 to avoid https://github.com/rubygems/rubygems/issues/7432
|
|
246
|
+
|
|
247
|
+
See [the INSTALLATION doc](https://github.com/sparklemotion/sqlite3-ruby/blob/main/INSTALLATION.md) for more information.
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
### Dependencies
|
|
251
|
+
|
|
252
|
+
- Vendored sqlite is updated to [v3.45.3](https://sqlite.org/releaselog/3_45_3.html). @flavorjones
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
### Added
|
|
256
|
+
|
|
257
|
+
- `Database#busy_handler_timeout=` introduced as an alternative to `#busy_timeout=` that can be used when it's desired to release the GVL between retries. [#443, #456] @fractaledmind
|
|
258
|
+
- Support the `SUPER_JOURNAL` flag which is an alias for `MASTER_JOURNAL` as of sqlite 3.33.0. [#467] @flavorjones
|
|
259
|
+
- `Statement#stat` and `Statement#memused` introduced to report statistics. [#461] @fractaledmind
|
|
260
|
+
- `Statement#sql` and `Statement#expanded_sql` introduced to retrieve the SQL statement associated with the `Statement` object. [#293, #498] @tenderlove
|
|
261
|
+
- `SQLite3.status` introduced to return run-time status and reset high-water marks. See `SQLite3::Constants::Status` for details. [#520] @wjlroe
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
### Improved
|
|
265
|
+
|
|
266
|
+
- Avoid leaking memory for statements that are not closed properly. [#392] @haileys
|
|
267
|
+
- Moved some C code into Ruby. [#451, #455] @tenderlove
|
|
268
|
+
- Improve performance of `ResultSet` hashes. [#154, #484, #468] @tenderlove
|
|
269
|
+
- Fix a GC compaction issue with `busy_handler`. [#466] @byroot
|
|
270
|
+
- Remove unused `ResultSet` instance variable. [#469] @tenderlove
|
|
271
|
+
- Fix encoding for values passed to custom functions. [#218, #488] @tenderlove
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
### Changed
|
|
275
|
+
|
|
276
|
+
- Consistently use `SQLite3::Exception` or subclasses. Previously some `Pragmas` methods raised `Exception`, and `Database#execute_batch2` and `Database#load_extension` raised `RuntimeError`. [#467, #490] @flavorjones
|
|
277
|
+
- `Database#columns` returns a list of internal frozen strings. [#155, #474, #486] @tenderlove
|
|
278
|
+
- Freeze results that come from the database. [#480] @tenderlove
|
|
279
|
+
- The encoding of a Database is no longer cached. [#485] @tenderlove
|
|
280
|
+
- `Database#transaction` returns the result of the block when used with a block. [#508] @alexcwatt
|
|
281
|
+
- `Database#execute_batch` returns the result of the last statement executed. [#512] @alexcwatt
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
### Removed
|
|
285
|
+
|
|
286
|
+
- Removed class `SQLite3::Translator` and all related type translation methods which have been deprecated since v1.3.2. [#470] @tenderlove
|
|
287
|
+
|
|
288
|
+
If you need to do type translation on values returned from the statement object, please wrap it
|
|
289
|
+
with a delegate object. Here is an example of using a delegate class to implement type
|
|
290
|
+
translation:
|
|
291
|
+
|
|
292
|
+
```ruby
|
|
293
|
+
require "sqlite3"
|
|
294
|
+
require "delegate"
|
|
295
|
+
|
|
296
|
+
db = SQLite3::Database.new(":memory:")
|
|
297
|
+
|
|
298
|
+
return_value = db.execute_batch2 <<-EOSQL
|
|
299
|
+
CREATE TABLE items (id integer PRIMARY KEY AUTOINCREMENT, name string);
|
|
300
|
+
INSERT INTO items (name) VALUES ("foo");
|
|
301
|
+
INSERT INTO items (name) VALUES ("bar");
|
|
302
|
+
EOSQL
|
|
303
|
+
|
|
304
|
+
class MyTranslator < DelegateClass(SQLite3::Statement)
|
|
305
|
+
def step
|
|
306
|
+
row = super
|
|
307
|
+
return if done?
|
|
308
|
+
|
|
309
|
+
row.map.with_index do |item, i|
|
|
310
|
+
case types[i]
|
|
311
|
+
when "integer" # turn all integers to floats
|
|
312
|
+
item.to_f
|
|
313
|
+
when "string" # add "hello" to all strings
|
|
314
|
+
item + "hello"
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
db.prepare("SELECT * FROM items") do |stmt|
|
|
321
|
+
stmt = MyTranslator.new(stmt)
|
|
322
|
+
while row = stmt.step
|
|
323
|
+
p row
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
- Removed `types` and `fields` readers on row objects, which have been deprecated since
|
|
329
|
+
v1.3.6. [#471] @tenderlove
|
|
330
|
+
|
|
331
|
+
Deprecated code looks like this:
|
|
332
|
+
|
|
333
|
+
```ruby
|
|
334
|
+
row = @db.execute("select * from foo")
|
|
335
|
+
assert_equal ["blob"], row.first.types
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
If you would like to access the "types" associated with a returned query,
|
|
339
|
+
use a prepared statement like this:
|
|
340
|
+
|
|
341
|
+
```ruby
|
|
342
|
+
@db.prepare("select * from foo") do |v|
|
|
343
|
+
assert_equal ["blob"], v.types
|
|
344
|
+
end
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
- Removed support for non-Array bind parameters to methods `Database#execute`, `#execute_batch`, and `#query`, which has been deprecated since v1.3.0. [#511] @flavorjones
|
|
348
|
+
|
|
349
|
+
Deprecated code looks like this:
|
|
350
|
+
|
|
351
|
+
``` ruby
|
|
352
|
+
@db.query("select * from foo where a = ? and b = ? and c = ?", 1, 2, 3)
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
For these cases, pass the bind parameters as an array:
|
|
356
|
+
|
|
357
|
+
``` ruby
|
|
358
|
+
@db.query("select * from foo where a = ? and b = ? and c = ?", [1, 2, 3])
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
- Removed class `SQLite3::VersionProxy` which has been deprecated since v1.3.2. [#453] @flavorjones
|
|
362
|
+
- Removed methods `SQLite3::Database::FunctionProxy#count` and `#set_error` which have been broken since at least v1.3.13. [#164, #509, #510] @alexcwatt @flavorjones
|
|
363
|
+
|
|
364
|
+
|
|
3
365
|
## 1.7.3 / 2024-03-15
|
|
4
366
|
|
|
5
367
|
### Dependencies
|
|
@@ -299,7 +661,7 @@ You can opt-out of the packaged version of sqlite (and use your system-installed
|
|
|
299
661
|
|
|
300
662
|
## 1.4.1
|
|
301
663
|
|
|
302
|
-
* Don't mandate dl functions for the
|
|
664
|
+
* Don't mandate dl functions for the extension build
|
|
303
665
|
* bumping version
|
|
304
666
|
|
|
305
667
|
|
data/CONTRIBUTING.md
CHANGED
|
@@ -5,6 +5,28 @@
|
|
|
5
5
|
This doc is a short introduction on how to modify and maintain the sqlite3-ruby gem.
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
## Architecture notes
|
|
9
|
+
|
|
10
|
+
### Decision record
|
|
11
|
+
|
|
12
|
+
As of 2024-09, we're starting to keep some architecture decisions in the subdirectory `/adr`, so
|
|
13
|
+
please look there for additional information.
|
|
14
|
+
|
|
15
|
+
### Garbage collection
|
|
16
|
+
|
|
17
|
+
All statements keep pointers back to their respective database connections.
|
|
18
|
+
The `@connection` instance variable on the `Statement` handle keeps the database
|
|
19
|
+
connection alive.
|
|
20
|
+
|
|
21
|
+
We use `sqlite3_close_v2` in `Database#close` since v2.1.0 which defers _actually_ closing the
|
|
22
|
+
connection and freeing the underlying memory until all open statements are closed; though the
|
|
23
|
+
`Database` object will immediately behave as though it's been fully closed. If a Database is not
|
|
24
|
+
explicitly closed, it will be closed when it is GCed.
|
|
25
|
+
|
|
26
|
+
`Statement#close` finalizes the underlying statement. If a Statement is not explicitly closed, it
|
|
27
|
+
will be closed/finalized when it is GCed.
|
|
28
|
+
|
|
29
|
+
|
|
8
30
|
## Building gems
|
|
9
31
|
|
|
10
32
|
As a prerequisite please make sure you have `docker` correctly installed, so that you're able to cross-compile the native gems.
|
|
@@ -23,12 +45,16 @@ Update `/dependencies.yml` to reflect:
|
|
|
23
45
|
|
|
24
46
|
## Making a release
|
|
25
47
|
|
|
26
|
-
A quick checklist:
|
|
48
|
+
A quick checklist to cutting a release of the sqlite3 gem:
|
|
27
49
|
|
|
28
50
|
- [ ] make sure CI is green!
|
|
29
|
-
-
|
|
30
|
-
- [ ]
|
|
31
|
-
- [ ] create a git tag using a format that matches the pattern `v\d+\.\d+\.\d+`, e.g. `v1.3.13`
|
|
32
|
-
-
|
|
33
|
-
- [ ] `
|
|
34
|
-
-
|
|
51
|
+
- bump the version
|
|
52
|
+
- [ ] update `CHANGELOG.md` and `lib/sqlite3/version.rb`
|
|
53
|
+
- [ ] create a git tag using a format that matches the pattern `v\d+\.\d+\.\d+`, e.g. `v1.3.13`
|
|
54
|
+
- build the native gems
|
|
55
|
+
- [ ] run `bin/build-gems` and make sure it completes and all the tests pass
|
|
56
|
+
- push
|
|
57
|
+
- [ ] `git push && git push --tags`
|
|
58
|
+
- [ ] `for g in gems/*.gem ; do gem push $g ; done`
|
|
59
|
+
- announce
|
|
60
|
+
- [ ] create a release at https://github.com/sparklemotion/sqlite3-ruby/releases and include sha2 checksums
|
data/FAQ.md
CHANGED
|
@@ -122,15 +122,17 @@ Placeholders in an SQL statement take any of the following formats:
|
|
|
122
122
|
* `?`
|
|
123
123
|
* `?_nnn_`
|
|
124
124
|
* `:_word_`
|
|
125
|
+
* `$_word_`
|
|
126
|
+
* `@_word_`
|
|
125
127
|
|
|
126
128
|
|
|
127
|
-
Where _n_ is an integer, and _word_ is an alpha-numeric identifier
|
|
128
|
-
|
|
129
|
-
identifies the index of the bind variable to replace it with.
|
|
130
|
-
is an identifier, it identifies the name of the corresponding bind
|
|
131
|
-
variable. (In the instance of the first format--a single question
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
Where _n_ is an integer, and _word_ is an alpha-numeric identifier(or number).
|
|
130
|
+
When the placeholder is associated with a number (only in case of `?_nnn_`),
|
|
131
|
+
that number identifies the index of the bind variable to replace it with.
|
|
132
|
+
When it is an identifier, it identifies the name of the corresponding bind
|
|
133
|
+
variable. (In the instance of the first format--a single question mark--the
|
|
134
|
+
placeholder is assigned a number one greater than the last index used, or 1
|
|
135
|
+
if it is the first.)
|
|
134
136
|
|
|
135
137
|
|
|
136
138
|
For example, here is a query using these placeholder formats:
|
|
@@ -207,48 +209,46 @@ Or do a `Database#prepare` to get the `Statement`, and then use either
|
|
|
207
209
|
stmt.bind_params( "value", "name" => "bob" )
|
|
208
210
|
```
|
|
209
211
|
|
|
210
|
-
## How do I discover metadata about a query?
|
|
212
|
+
## How do I discover metadata about a query result?
|
|
211
213
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
+
IMPORTANT: `Database#execute` returns an Array of Array of Strings
|
|
215
|
+
which will have no metadata about the query or the result, such
|
|
216
|
+
as column names.
|
|
214
217
|
|
|
215
218
|
|
|
216
|
-
|
|
217
|
-
property "fields" that returns an array of the column names. The row
|
|
218
|
-
will also have a property "types" that returns an array of the column
|
|
219
|
-
types:
|
|
219
|
+
There are 2 main sources of query metadata:
|
|
220
220
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
rows = db.execute( "select * from table" )
|
|
224
|
-
p rows[0].fields
|
|
225
|
-
p rows[0].types
|
|
226
|
-
```
|
|
221
|
+
* `Statement`
|
|
222
|
+
* `ResultSet`
|
|
227
223
|
|
|
228
224
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
you still need the metadata, you can use `Database#query` and ask the
|
|
232
|
-
`ResultSet` object itself:
|
|
225
|
+
You can get a `Statement` via `Database#prepare`, and you can get
|
|
226
|
+
a `ResultSet` via `Statement#execute` or `Database#query`.
|
|
233
227
|
|
|
234
228
|
|
|
235
229
|
```ruby
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
230
|
+
sql = 'select * from table'
|
|
231
|
+
|
|
232
|
+
# No metadata
|
|
233
|
+
rows = db.execute(sql)
|
|
234
|
+
rows.class # => Array, no metadata
|
|
235
|
+
rows.first.class # => Array, no metadata
|
|
236
|
+
rows.first.first.class #=> String, no metadata
|
|
237
|
+
|
|
238
|
+
# Statement has metadata
|
|
239
|
+
stmt = db.prepare(sql)
|
|
240
|
+
stmt.columns # => [ ... ]
|
|
241
|
+
stmt.types # => [ ... ]
|
|
242
|
+
|
|
243
|
+
# ResultSet has metadata
|
|
244
|
+
results = stmt.execute
|
|
245
|
+
results.columns # => [ ... ]
|
|
246
|
+
results.types # => [ ... ]
|
|
247
|
+
|
|
248
|
+
# ResultSet has metadata
|
|
249
|
+
results = db.query(sql)
|
|
250
|
+
results.columns # => [ ... ]
|
|
251
|
+
results.types # => [ ... ]
|
|
252
252
|
```
|
|
253
253
|
|
|
254
254
|
## I'd like the rows to be indexible by column name.
|
|
@@ -273,7 +273,18 @@ is unavailable on the row, although the "types" property remains.)
|
|
|
273
273
|
```
|
|
274
274
|
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
A more granular way to do this is via `ResultSet#next_hash` or
|
|
277
|
+
`ResultSet#each_hash`.
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
```ruby
|
|
281
|
+
results = db.query( "select * from table" )
|
|
282
|
+
row = results.next_hash
|
|
283
|
+
p row['column1']
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
Another way is to use Ara Howard's
|
|
277
288
|
[`ArrayFields`](http://rubyforge.org/projects/arrayfields)
|
|
278
289
|
module. Just `require "arrayfields"`, and all of your rows will be indexable
|
|
279
290
|
by column name, even though they are still arrays!
|
|
@@ -289,49 +300,6 @@ by column name, even though they are still arrays!
|
|
|
289
300
|
end
|
|
290
301
|
```
|
|
291
302
|
|
|
292
|
-
## I'd like the values from a query to be the correct types, instead of String.
|
|
293
|
-
|
|
294
|
-
You can turn on "type translation" by setting `Database#type_translation` to
|
|
295
|
-
true:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
```ruby
|
|
299
|
-
db.type_translation = true
|
|
300
|
-
db.execute( "select * from table" ) do |row|
|
|
301
|
-
p row
|
|
302
|
-
end
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
By doing this, each return value for each row will be translated to its
|
|
307
|
-
correct type, based on its declared column type.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
You can even declare your own translation routines, if (for example) you are
|
|
311
|
-
using an SQL type that is not handled by default:
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
```ruby
|
|
315
|
-
# assume "objects" table has the following schema:
|
|
316
|
-
# create table objects (
|
|
317
|
-
# name varchar2(20),
|
|
318
|
-
# thing object
|
|
319
|
-
# )
|
|
320
|
-
|
|
321
|
-
db.type_translation = true
|
|
322
|
-
db.translator.add_translator( "object" ) do |type, value|
|
|
323
|
-
db.decode( value )
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
h = { :one=>:two, "three"=>"four", 5=>6 }
|
|
327
|
-
dump = db.encode( h )
|
|
328
|
-
|
|
329
|
-
db.execute( "insert into objects values ( ?, ? )", "bob", dump )
|
|
330
|
-
|
|
331
|
-
obj = db.get_first_value( "select thing from objects where name='bob'" )
|
|
332
|
-
p obj == h
|
|
333
|
-
```
|
|
334
|
-
|
|
335
303
|
## How do I insert binary data into the database?
|
|
336
304
|
|
|
337
305
|
Use blobs. Blobs are new features of SQLite3. You have to use bind
|
data/INSTALLATION.md
CHANGED
|
@@ -7,32 +7,38 @@ This document will help you install the `sqlite3` ruby gem. It also contains ins
|
|
|
7
7
|
|
|
8
8
|
### Native Gems (recommended)
|
|
9
9
|
|
|
10
|
-
In
|
|
10
|
+
In v2.5.0 and later, native (precompiled) gems are available for recent Ruby versions on these platforms:
|
|
11
11
|
|
|
12
|
-
- `aarch64-linux` (requires: glibc >= 2.29)
|
|
13
|
-
- `
|
|
12
|
+
- `aarch64-linux-gnu` (requires: glibc >= 2.29)
|
|
13
|
+
- `aarch64-linux-musl`
|
|
14
|
+
- `arm-linux-gnu` (requires: glibc >= 2.29)
|
|
15
|
+
- `arm-linux-musl`
|
|
14
16
|
- `arm64-darwin`
|
|
15
|
-
- `x64-
|
|
16
|
-
- `x86-linux` (requires: glibc >= 2.
|
|
17
|
+
- `x64-mingw-ucrt`
|
|
18
|
+
- `x86-linux-gnu` (requires: glibc >= 2.29)
|
|
19
|
+
- `x86-linux-musl`
|
|
17
20
|
- `x86_64-darwin`
|
|
18
|
-
- `x86_64-linux` (requires: glibc >= 2.
|
|
21
|
+
- `x86_64-linux-gnu` (requires: glibc >= 2.29)
|
|
22
|
+
- `x86_64-linux-musl`
|
|
23
|
+
|
|
24
|
+
⚠ Musl linux users should update to Bundler >= 2.5.6 to avoid https://github.com/rubygems/rubygems/issues/7432
|
|
19
25
|
|
|
20
26
|
If you are using one of these Ruby versions on one of these platforms, the native gem is the recommended way to install sqlite3-ruby.
|
|
21
27
|
|
|
22
|
-
For example, on a linux system running Ruby 3.
|
|
28
|
+
For example, on a linux system running Ruby 3.4:
|
|
23
29
|
|
|
24
30
|
``` text
|
|
25
31
|
$ ruby -v
|
|
26
|
-
ruby 3.
|
|
32
|
+
ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [x86_64-linux]
|
|
27
33
|
|
|
28
34
|
$ time gem install sqlite3
|
|
29
|
-
Fetching sqlite3-
|
|
30
|
-
Successfully installed sqlite3-
|
|
35
|
+
Fetching sqlite3-2.8.1-x86_64-linux-gnu.gem
|
|
36
|
+
Successfully installed sqlite3-2.8.1-x86_64-linux-gnu
|
|
31
37
|
1 gem installed
|
|
32
38
|
|
|
33
|
-
real
|
|
34
|
-
user 0m0.
|
|
35
|
-
sys 0m0.
|
|
39
|
+
real 0m1.273s
|
|
40
|
+
user 0m0.496s
|
|
41
|
+
sys 0m0.078s
|
|
36
42
|
```
|
|
37
43
|
|
|
38
44
|
#### Avoiding the precompiled native gem
|
|
@@ -57,6 +63,8 @@ If you are on a platform or version of Ruby that is not covered by the Native Ge
|
|
|
57
63
|
|
|
58
64
|
By default, as of v1.5.0 of this library, the latest available version of libsqlite3 is packaged with the gem and will be compiled and used automatically. This takes a bit longer than the native gem, but will provide a modern, well-supported version of libsqlite3.
|
|
59
65
|
|
|
66
|
+
⚠ A prerequisite to build the gem with the packaged sqlite3 is that you must have `pkgconf` installed.
|
|
67
|
+
|
|
60
68
|
For example, on a linux system running Ruby 2.5:
|
|
61
69
|
|
|
62
70
|
``` text
|