sqlite3 1.7.3-aarch64-linux → 2.9.5

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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +394 -1
  3. data/CONTRIBUTING.md +37 -6
  4. data/FAQ.md +52 -84
  5. data/INSTALLATION.md +21 -13
  6. data/LICENSE +18 -22
  7. data/README.md +97 -9
  8. data/dependencies.yml +10 -11
  9. data/ext/sqlite3/aggregator.c +143 -146
  10. data/ext/sqlite3/aggregator.h +2 -4
  11. data/ext/sqlite3/backup.c +74 -65
  12. data/ext/sqlite3/backup.h +2 -2
  13. data/ext/sqlite3/database.c +619 -495
  14. data/ext/sqlite3/database.h +13 -4
  15. data/ext/sqlite3/exception.c +116 -92
  16. data/ext/sqlite3/exception.h +5 -1
  17. data/ext/sqlite3/extconf.rb +39 -27
  18. data/ext/sqlite3/sqlite3.c +176 -115
  19. data/ext/sqlite3/sqlite3_ruby.h +2 -2
  20. data/ext/sqlite3/statement.c +588 -300
  21. data/ext/sqlite3/statement.h +4 -3
  22. data/ext/sqlite3/timespec.h +20 -0
  23. data/lib/sqlite3/constants.rb +195 -47
  24. data/lib/sqlite3/database.rb +228 -187
  25. data/lib/sqlite3/errors.rb +54 -1
  26. data/lib/sqlite3/fork_safety.rb +66 -0
  27. data/lib/sqlite3/pragmas.rb +194 -141
  28. data/lib/sqlite3/resultset.rb +14 -97
  29. data/lib/sqlite3/statement.rb +58 -13
  30. data/lib/sqlite3/value.rb +17 -20
  31. data/lib/sqlite3/version.rb +2 -21
  32. data/lib/sqlite3/version_info.rb +17 -0
  33. data/lib/sqlite3.rb +8 -4
  34. data/ports/archives/sqlite-autoconf-3530200.tar.gz +0 -0
  35. metadata +28 -45
  36. data/API_CHANGES.md +0 -49
  37. data/ChangeLog.cvs +0 -88
  38. data/Gemfile +0 -10
  39. data/LICENSE-DEPENDENCIES +0 -20
  40. data/lib/sqlite3/3.0/sqlite3_native.so +0 -0
  41. data/lib/sqlite3/3.1/sqlite3_native.so +0 -0
  42. data/lib/sqlite3/3.2/sqlite3_native.so +0 -0
  43. data/lib/sqlite3/3.3/sqlite3_native.so +0 -0
  44. data/lib/sqlite3/translator.rb +0 -117
  45. data/test/helper.rb +0 -27
  46. data/test/test_backup.rb +0 -33
  47. data/test/test_collation.rb +0 -82
  48. data/test/test_database.rb +0 -668
  49. data/test/test_database_flags.rb +0 -95
  50. data/test/test_database_readonly.rb +0 -36
  51. data/test/test_database_readwrite.rb +0 -41
  52. data/test/test_deprecated.rb +0 -49
  53. data/test/test_encoding.rb +0 -165
  54. data/test/test_integration.rb +0 -507
  55. data/test/test_integration_aggregate.rb +0 -336
  56. data/test/test_integration_open_close.rb +0 -30
  57. data/test/test_integration_pending.rb +0 -115
  58. data/test/test_integration_resultset.rb +0 -142
  59. data/test/test_integration_statement.rb +0 -194
  60. data/test/test_pragmas.rb +0 -22
  61. data/test/test_result_set.rb +0 -47
  62. data/test/test_sqlite3.rb +0 -30
  63. data/test/test_statement.rb +0 -290
  64. data/test/test_statement_execute.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 837bb496b0c150e3ed8e21e5c0f56366ca4a45e9cfa492f27ee3b21ecadcdbd4
4
- data.tar.gz: c313e8711ef29344f2e022fadc38184abd14b9af51d8e7b18888736f94558fcd
3
+ metadata.gz: d07346cdcb69a6187d144247aefa90dbf7b2966513f94643e20baa18dd38fbbf
4
+ data.tar.gz: e1c7385c0d16942a8b3b9fc4976b486e1b1fed18524975e0d53a608d542a2943
5
5
  SHA512:
6
- metadata.gz: 36533b4e40b0498e7fb0e5d3003ca11b61c142d2c5e91017f6e1c3de659b475d680329f7a84af2fabcd620578c675da726657b4aacac093a785dcdc4333d62d6
7
- data.tar.gz: 80031abfa246e43c49bb24cf0e81339f4984382c005fdf8340d78d652e83a09aeb1b0acfa8be21dfa0888d080e062d7bcd677dc574fee717922636daec43c8f2
6
+ metadata.gz: 0e95401b70a9780e5e5a1903e3b9cf3d0aa588e75c89db0211642918d83305132b06ab169ee519633d507fc27a1d6674e344162acae905c8fe14478850a3b3cf
7
+ data.tar.gz: ab4fb4b3a3b7dba95cbb0e7cbb893c9223de6f5ca82469ac68f35f6b89293bc2ba8292cd5d561cfb245e038769880b60edb6a4896a4b9072305661dda2f9e999
data/CHANGELOG.md CHANGED
@@ -1,5 +1,398 @@
1
1
  # sqlite3-ruby Changelog
2
2
 
3
+ ## 2.9.5 / 2026-06-07
4
+
5
+ ### Dependencies
6
+
7
+ - Vendored sqlite is updated to [v3.53.2](https://www.sqlite.org/releaselog/3_53_3.html) (from v3.53.1). #709 @flavorjones
8
+
9
+ ### Security / Stability
10
+
11
+ - Fix use-after-free issue with custom functions, when the same function name is used with multiple arities. See https://github.com/sparklemotion/sqlite3-ruby/security/advisories/GHSA-28hh-pr2h-2w89 for more information. #710 @flavorjones
12
+ - Fix use-after-free issue with aggregate functions, if a statement is used after a soft database close. See https://github.com/sparklemotion/sqlite3-ruby/security/advisories/GHSA-j7fr-3v8c-3qc3 for more information. #711 @flavorjones
13
+
14
+
15
+ ## 2.9.4 / 2026-05-05
16
+
17
+ - Vendored sqlite is updated to [v3.53.1](https://www.sqlite.org/releaselog/3_53_1.html) (from v3.53.0). #704 @flavorjones
18
+
19
+
20
+ ## 2.9.3 / 2026-04-15
21
+
22
+ - Vendored sqlite is updated to [v3.53.0](https://www.sqlite.org/releaselog/3_53_0.html) (from v3.51.3). #696 @flavorjones
23
+
24
+
25
+ ## 2.9.2 / 2026-03-15
26
+
27
+ - Vendored sqlite is updated to [v3.51.3](https://www.sqlite.org/releaselog/3_51_3.html) (from v3.51.2). #688 @flavorjones
28
+
29
+
30
+ ## 2.9.1 / 2026-02-28
31
+
32
+ - Vendored sqlite is updated to [v3.51.2](https://www.sqlite.org/releaselog/3_51_2.html) (from v3.51.1). #683 @flavorjones
33
+
34
+ ## 2.9.0 / 2025-12-27
35
+
36
+ ### Ruby
37
+
38
+ - Introduce native gem packages for Ruby 4.0. @flavorjones
39
+ - Drop support for Ruby 3.1. @flavorjones
40
+
41
+ ### Added
42
+
43
+ - Introduce `Statement#named_params` to introspect on a parameterized SQL statement. #627 #642 @captn3m0
44
+
45
+ ### Improved
46
+
47
+ - Small improvements to docstrings and comments. @flavorjones @houyuanjie
48
+
49
+
50
+ ## 2.8.1 / 2025-11-29
51
+
52
+ - Vendored sqlite is updated to [v3.51.1](https://www.sqlite.org/releaselog/3_51_1.html) (from v3.51.0). #659 @flavorjones
53
+ - Precompiled native gems are built with rake-compiler-dock v1.10.0 (previously v1.9.1).
54
+
55
+
56
+ ## 2.8.0 / 2025-11-05
57
+
58
+ - Vendored sqlite is updated to [v3.51.0](https://www.sqlite.org/releaselog/3_51_0.html) (from v3.50.4). #652 @flavorjones
59
+
60
+
61
+ ## 2.7.4 / 2025-09-19
62
+
63
+ - Vendored sqlite is updated to [v3.50.4](https://www.sqlite.org/releaselog/3_50_4.html) (from v3.50.3). #644 @flavorjones
64
+
65
+
66
+ ## 2.7.3 / 2025-07-18
67
+
68
+ - Vendored sqlite is updated to [v3.50.3](https://sqlite.org/releaselog/3_50_3.html) (from v3.50.2). #638 @flavorjones
69
+
70
+
71
+ ## 2.7.2 / 2025-07-05
72
+
73
+ - 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
74
+
75
+
76
+ ## 2.7.1 / 2025-06-30
77
+
78
+ - Vendored sqlite is updated to [v3.50.2](https://sqlite.org/releaselog/3_50_2.html) (from v3.50.1). #633 @flavorjones
79
+
80
+
81
+ ## 2.7.0 / 2025-06-09
82
+
83
+ - Vendored sqlite is updated to [v3.50.1](https://sqlite.org/releaselog/3_50_1.html) (from v3.49.1). #630 @flavorjones
84
+
85
+
86
+ ## 2.6.0 / 2025-02-20
87
+
88
+ ### Dependencies
89
+
90
+ - Vendored sqlite is updated to [v3.49.1](https://sqlite.org/releaselog/3_49_1.html) (from v3.47.2). #605 @flavorjones
91
+ - Updated to rake-compiler-dock v1.9.1. #610 @flavorjones
92
+
93
+ ### Important note for Window users
94
+
95
+ 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.
96
+
97
+ 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.
98
+
99
+ 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.
100
+
101
+ If you are willing and able to help fix this, let us know at https://github.com/sparklemotion/sqlite3-ruby/issues/618.
102
+
103
+
104
+ ## 2.5.0 / 2024-12-25
105
+
106
+ ### Ruby
107
+
108
+ This release introduces native gem packages that include Ruby 3.4.
109
+
110
+
111
+ ## 2.4.1 / 2024-12-08
112
+
113
+ ### Dependencies
114
+
115
+ - Vendored sqlite is updated to [v3.47.2](https://sqlite.org/releaselog/3_47.2.html) #593 @flavorjones
116
+
117
+ The description from the upstream maintainers is:
118
+
119
+ > SQLite version 3.47.2, now available, fixes an important bug that first appeared in the 3.47.0
120
+ > release. In SQLite versions 3.47.0 and 3.47.1, if you try to convert a string into a
121
+ > floating-point value and the first 16 significant digits of the value are exactly
122
+ > "1844674407370955", then the floating-point number generated might be incorrect. The problem
123
+ > only affects x64 and i386 CPUs, so it does not affect you if you are running on ARM. And it only
124
+ > affects releases 3.47.0 and 3.47.1. **If you are running SQLite versions 3.47.0 or 3.47.1, then
125
+ > upgrading is recommended.**
126
+
127
+ Saving you a click, you should upgrade if you're running sqlite3-ruby v2.1.1 or later.
128
+
129
+
130
+ ### Fixed
131
+
132
+ - Prevent unnecessary "Invalid Reference" warnings from the `ForkSafety` module when GC runs during the "after fork" hook. #592 @flavorjones
133
+
134
+
135
+ ## 2.4.0 / 2024-12-03
136
+
137
+ ### Added
138
+
139
+ - `Database#load_extension` now accepts any object that responds to `#to_path`, in addition to String filesystem paths. [#586] @flavorjones
140
+ - `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
141
+
142
+
143
+ ## 2.3.1 / 2024-11-25
144
+
145
+ ### Dependencies
146
+
147
+ - Vendored sqlite is updated to [v3.47.1](https://sqlite.org/releaselog/3_47_1.html) [#589] @flavorjones
148
+
149
+
150
+ ## 2.3.0 / 2024-11-20
151
+
152
+ ### Added
153
+
154
+ - 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
155
+ - 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
156
+ - `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
157
+ - `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
158
+
159
+
160
+ ### Fixed
161
+
162
+ - `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
163
+ - Omit mention of the `pkg-config` gem when failing to build from source, since it is not used. [#358] @flavorjones
164
+
165
+
166
+ ## 2.2.0 / 2024-10-30
167
+
168
+ ### Added
169
+
170
+ - 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
171
+
172
+
173
+ ### Improved
174
+
175
+ - 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
176
+
177
+
178
+ ## 2.1.1 / 2024-10-22
179
+
180
+ ### Dependencies
181
+
182
+ - Vendored sqlite is updated to [v3.47.0](https://sqlite.org/releaselog/3_47_0.html) [#570] @flavorjones
183
+
184
+
185
+ ## 2.1.0 / 2024-09-24
186
+
187
+ ### Ruby
188
+
189
+ - This release drops support for Ruby 3.0. [#563] @flavorjones
190
+
191
+
192
+ ### Fork safety improvements
193
+
194
+ 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:
195
+
196
+ - 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.
197
+ - These connections will be incompletely closed ("discarded") which will result in a one-time memory leak in the child process.
198
+
199
+ 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!`.
200
+
201
+ See the README's "Fork Safety" section and `adr/2024-09-fork-safety.md` for more information. [#558, #565, #566] @flavorjones
202
+
203
+
204
+ ### Improved
205
+
206
+ - 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
207
+ - When setting a Database `busy_handler`, fire the write barrier to prevent potential crashes during the GC mark phase. [#556] @jhawthorn
208
+
209
+
210
+ ### Documentation
211
+
212
+ - The `FAQ.md` has been updated to fix some inaccuracies. [#562] @rickhull
213
+
214
+
215
+ ## 2.0.4 / 2024-08-13
216
+
217
+ ### Dependencies
218
+
219
+ - Vendored sqlite is updated to [v3.46.1](https://sqlite.org/releaselog/3_46_1.html) @flavorjones
220
+
221
+
222
+ ## 2.0.3 / 2024-07-29
223
+
224
+ ### Improved
225
+
226
+ - `Database#quote` avoids allocating strings where reusing frozen strings is preferable. #548 @casperisfine
227
+
228
+
229
+ ## 2.0.2 / 2024-05-23
230
+
231
+ ### Dependencies
232
+
233
+ - Vendored sqlite is updated to [v3.46.0](https://sqlite.org/releaselog/3_46_0.html) @flavorjones
234
+
235
+
236
+ ## 2.0.1 / 2024-04-20
237
+
238
+ ### Fixed
239
+
240
+ - 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
241
+ - 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
242
+
243
+
244
+ ## 2.0.0 / 2024-04-17
245
+
246
+ This is a major release which contains some breaking changes, primarily the removal of
247
+ long-deprecated functionality. Before upgrading, please make sure to address deprecation warnings
248
+ emitted from your application using sqlite3-ruby v1.7.x.
249
+
250
+
251
+ ### Ruby
252
+
253
+ - This release drops support for Ruby 2.7. [#453] @flavorjones
254
+
255
+
256
+ ### Packaging
257
+
258
+ Native (precompiled) gems are now available for Linux Musl. [#442] @flavorjones
259
+
260
+ Here are the platforms for which native gems are shipped:
261
+
262
+ - `aarch64-linux-gnu` (requires: glibc >= 2.29)
263
+ - `aarch64-linux-musl`
264
+ - `arm-linux-gnu` (requires: glibc >= 2.29)
265
+ - `arm-linux-musl`
266
+ - `arm64-darwin`
267
+ - `x64-mingw32` / `x64-mingw-ucrt`
268
+ - `x86-linux-gnu` (requires: glibc >= 2.17)
269
+ - `x86-linux-musl`
270
+ - `x86_64-darwin`
271
+ - `x86_64-linux-gnu` (requires: glibc >= 2.17)
272
+ - `x86_64-linux-musl`
273
+
274
+ ⚠ Ruby 3.0 linux users must use Rubygems >= 3.3.22 in order to use these gems.
275
+
276
+ ⚠ Musl linux users should update to Bundler >= 2.5.6 to avoid https://github.com/rubygems/rubygems/issues/7432
277
+
278
+ See [the INSTALLATION doc](https://github.com/sparklemotion/sqlite3-ruby/blob/main/INSTALLATION.md) for more information.
279
+
280
+
281
+ ### Dependencies
282
+
283
+ - Vendored sqlite is updated to [v3.45.3](https://sqlite.org/releaselog/3_45_3.html). @flavorjones
284
+
285
+
286
+ ### Added
287
+
288
+ - `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
289
+ - Support the `SUPER_JOURNAL` flag which is an alias for `MASTER_JOURNAL` as of sqlite 3.33.0. [#467] @flavorjones
290
+ - `Statement#stat` and `Statement#memused` introduced to report statistics. [#461] @fractaledmind
291
+ - `Statement#sql` and `Statement#expanded_sql` introduced to retrieve the SQL statement associated with the `Statement` object. [#293, #498] @tenderlove
292
+ - `SQLite3.status` introduced to return run-time status and reset high-water marks. See `SQLite3::Constants::Status` for details. [#520] @wjlroe
293
+
294
+
295
+ ### Improved
296
+
297
+ - Avoid leaking memory for statements that are not closed properly. [#392] @haileys
298
+ - Moved some C code into Ruby. [#451, #455] @tenderlove
299
+ - Improve performance of `ResultSet` hashes. [#154, #484, #468] @tenderlove
300
+ - Fix a GC compaction issue with `busy_handler`. [#466] @byroot
301
+ - Remove unused `ResultSet` instance variable. [#469] @tenderlove
302
+ - Fix encoding for values passed to custom functions. [#218, #488] @tenderlove
303
+
304
+
305
+ ### Changed
306
+
307
+ - 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
308
+ - `Database#columns` returns a list of internal frozen strings. [#155, #474, #486] @tenderlove
309
+ - Freeze results that come from the database. [#480] @tenderlove
310
+ - The encoding of a Database is no longer cached. [#485] @tenderlove
311
+ - `Database#transaction` returns the result of the block when used with a block. [#508] @alexcwatt
312
+ - `Database#execute_batch` returns the result of the last statement executed. [#512] @alexcwatt
313
+
314
+
315
+ ### Removed
316
+
317
+ - Removed class `SQLite3::Translator` and all related type translation methods which have been deprecated since v1.3.2. [#470] @tenderlove
318
+
319
+ If you need to do type translation on values returned from the statement object, please wrap it
320
+ with a delegate object. Here is an example of using a delegate class to implement type
321
+ translation:
322
+
323
+ ```ruby
324
+ require "sqlite3"
325
+ require "delegate"
326
+
327
+ db = SQLite3::Database.new(":memory:")
328
+
329
+ return_value = db.execute_batch2 <<-EOSQL
330
+ CREATE TABLE items (id integer PRIMARY KEY AUTOINCREMENT, name string);
331
+ INSERT INTO items (name) VALUES ("foo");
332
+ INSERT INTO items (name) VALUES ("bar");
333
+ EOSQL
334
+
335
+ class MyTranslator < DelegateClass(SQLite3::Statement)
336
+ def step
337
+ row = super
338
+ return if done?
339
+
340
+ row.map.with_index do |item, i|
341
+ case types[i]
342
+ when "integer" # turn all integers to floats
343
+ item.to_f
344
+ when "string" # add "hello" to all strings
345
+ item + "hello"
346
+ end
347
+ end
348
+ end
349
+ end
350
+
351
+ db.prepare("SELECT * FROM items") do |stmt|
352
+ stmt = MyTranslator.new(stmt)
353
+ while row = stmt.step
354
+ p row
355
+ end
356
+ end
357
+ ```
358
+
359
+ - Removed `types` and `fields` readers on row objects, which have been deprecated since
360
+ v1.3.6. [#471] @tenderlove
361
+
362
+ Deprecated code looks like this:
363
+
364
+ ```ruby
365
+ row = @db.execute("select * from foo")
366
+ assert_equal ["blob"], row.first.types
367
+ ```
368
+
369
+ If you would like to access the "types" associated with a returned query,
370
+ use a prepared statement like this:
371
+
372
+ ```ruby
373
+ @db.prepare("select * from foo") do |v|
374
+ assert_equal ["blob"], v.types
375
+ end
376
+ ```
377
+
378
+ - 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
379
+
380
+ Deprecated code looks like this:
381
+
382
+ ``` ruby
383
+ @db.query("select * from foo where a = ? and b = ? and c = ?", 1, 2, 3)
384
+ ```
385
+
386
+ For these cases, pass the bind parameters as an array:
387
+
388
+ ``` ruby
389
+ @db.query("select * from foo where a = ? and b = ? and c = ?", [1, 2, 3])
390
+ ```
391
+
392
+ - Removed class `SQLite3::VersionProxy` which has been deprecated since v1.3.2. [#453] @flavorjones
393
+ - Removed methods `SQLite3::Database::FunctionProxy#count` and `#set_error` which have been broken since at least v1.3.13. [#164, #509, #510] @alexcwatt @flavorjones
394
+
395
+
3
396
  ## 1.7.3 / 2024-03-15
4
397
 
5
398
  ### Dependencies
@@ -299,7 +692,7 @@ You can opt-out of the packaged version of sqlite (and use your system-installed
299
692
 
300
693
  ## 1.4.1
301
694
 
302
- * Don't mandate dl functions for the extention build
695
+ * Don't mandate dl functions for the extension build
303
696
  * bumping version
304
697
 
305
698
 
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,21 @@ 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
- - [ ] make sure CI is green!
29
- - [ ] update `CHANGELOG.md` and `lib/sqlite3/version.rb` including `VersionProxy::{MINOR,TINY}`
30
- - [ ] run `bin/build-gems` and make sure it completes and all the tests pass
31
- - [ ] create a git tag using a format that matches the pattern `v\d+\.\d+\.\d+`, e.g. `v1.3.13`
50
+ Prep
51
+ - [ ] Make sure CI is green!
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`
32
54
  - [ ] `git push && git push --tags`
55
+
56
+ Automated build and release
57
+ - [ ] Run workflow https://github.com/sparklemotion/sqlite3-ruby/actions/workflows/release.yml
58
+ - [ ] Copy checksums from the push job
59
+
60
+ Manual build and release
61
+ - [ ] Run `bin/build-gems` and make sure it completes and all the tests pass
33
62
  - [ ] `for g in gems/*.gem ; do gem push $g ; done`
34
- - [ ] create a release at https://github.com/sparklemotion/sqlite3-ruby/releases and include sha2 checksums
63
+
64
+ Post-release
65
+ - [ ] 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 (or
128
- number). When the placeholder is associated with a number, that number
129
- identifies the index of the bind variable to replace it with. When it
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
- mark--the placeholder is assigned a number one greater than the last
133
- index used, or 1 if it is the first.)
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
- If you ever want to know the names or types of the columns in a result
213
- set, you can do it in several ways.
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
- The first way is to ask the row object itself. Each row will have a
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
- ```ruby
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
- Obviously, this approach requires you to execute a statement that actually
230
- returns data. If you don't know if the statement will return any rows, but
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
- db.query( "select * from table" ) do |result|
237
- p result.columns
238
- p result.types
239
- ...
240
- end
241
- ```
242
-
243
-
244
- Lastly, you can use `Database#prepare` and ask the `Statement` object what
245
- the metadata are:
246
-
247
-
248
- ```ruby
249
- stmt = db.prepare( "select * from table" )
250
- p stmt.columns
251
- p stmt.types
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
- The other way is to use Ara Howard's
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