sqlite3-ffi 0.1.3 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c829fe23eea2a7239e16ef5ceca82d90b911402f7f887eed32b61ecd3703b48d
4
- data.tar.gz: f698015784c3dd82de0202b793c1ad9f19d0e8056d40614b05825704c2973b0f
3
+ metadata.gz: 18966e30363b64785e729d7083ee0595f4041adf38ef397c1ab537d3df2f4915
4
+ data.tar.gz: 5dcbab4cf2535a6b8b562eeaa91179728a147f38ef2309e028a508189afcbb0f
5
5
  SHA512:
6
- metadata.gz: 39ba82fe3ca0ef1544a3e01c20bb07ba5d95191f7c64113af5e5e7b5feffa162bba0532bceadd6856e39e5caf884dd5fcafe61a53187c7986e1a02c22e821dad
7
- data.tar.gz: 81a428f53c798cd099943568a1e8e43bd8f0322a713e46a1b390ace952e416d5cd2c3fb1985c1ffea24d27b86fceefa0281031698812e50972fcf5d4eb683878
6
+ metadata.gz: 2e91e7e66411e91ccc35c6b1d2525f0f766bf7893200db4db9b6ea8ed9647c22a39756649abf9f429e0c4d13dd3b717d4d733b46c5ef3ac24062174717a5452b
7
+ data.tar.gz: bb42912806d022e3e5ffcc7b11c0ef18a81d2545191da9cd30e90ad05e46f697c9d2c8e915419911b4a42264cd801866a2be74ed55f68dadec06a6c900733181
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.1.5 (2026-01-02)
2
+
3
+ - Synced with sqlite3-ruby 2.9.0
4
+
5
+ ## 0.1.4 (2025-06-09)
6
+
7
+ - Synced with sqlite3-ruby 2.7.0
8
+
1
9
  ## 0.1.3 (2025-06-07)
2
10
 
3
11
  - Prefer SQLite from Homebrew on Mac
@@ -82,6 +82,7 @@ module SQLite3
82
82
  # extensions:
83
83
  # - .sqlpkg/nalgeon/crypto/crypto.so # a filesystem path
84
84
  # - <%= SQLean::UUID.to_path %> # or ruby code returning a path
85
+ # - SQLean::Crypto # Rails 8.1+ accepts the name of a constant that responds to `to_path`
85
86
  #
86
87
  class Database
87
88
  attr_reader :collations
@@ -196,7 +197,7 @@ module SQLite3
196
197
  #
197
198
  # Fetch the encoding set on this database
198
199
  def encoding
199
- prepare("PRAGMA encoding") { |stmt| Encoding.find(stmt.first.first) }
200
+ Encoding.find super
200
201
  end
201
202
 
202
203
  # Installs (or removes) a block that will be invoked for every access
@@ -19,7 +19,7 @@ module SQLite3
19
19
  inst_ptr = CApi.sqlite3_aggregate_context(ctx, 8)
20
20
 
21
21
  if inst_ptr.null?
22
- fatal "SQLite is out-of-merory"
22
+ fatal "SQLite is out-of-memory"
23
23
  end
24
24
 
25
25
  if inst_ptr.read_pointer.null?
@@ -141,6 +141,7 @@ module SQLite3
141
141
  attach_function :sqlite3_bind_null, [:pointer, :int], :int
142
142
  attach_function :sqlite3_bind_parameter_count, [:pointer], :int
143
143
  attach_function :sqlite3_bind_parameter_index, [:pointer, :string], :int
144
+ attach_function :sqlite3_bind_parameter_name, [:pointer, :int], :string
144
145
  attach_function :sqlite3_bind_text, [:pointer, :int, :string, :int, :pointer], :int
145
146
  attach_function :sqlite3_bind_text16, [:pointer, :int, :pointer, :int, :pointer], :int
146
147
  attach_function :sqlite3_busy_handler, [:pointer, :pointer, :pointer], :int
@@ -178,6 +178,23 @@ module SQLite3
178
178
  FFI::CApi.sqlite3_bind_parameter_count(@stmt)
179
179
  end
180
180
 
181
+ def named_params
182
+ require_live_db
183
+ require_open_stmt
184
+
185
+ param_count = FFI::CApi.sqlite3_bind_parameter_count(@stmt)
186
+ params = []
187
+
188
+ 1.upto(param_count) do |i|
189
+ name = FFI::CApi.sqlite3_bind_parameter_name(@stmt, i)
190
+ if name && name[0] != "?"
191
+ param = FFI.interned_utf8_cstr(name[1..])
192
+ params << param
193
+ end
194
+ end
195
+ params.freeze
196
+ end
197
+
181
198
  STMT_STAT_SYMBOLS = {
182
199
  fullscan_steps: FFI::CApi::SQLITE_STMTSTATUS_FULLSCAN_STEP,
183
200
  sorts: FFI::CApi::SQLITE_STMTSTATUS_SORT,
@@ -1,5 +1,5 @@
1
1
  module SQLite3
2
2
  module FFI
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sqlite3/errors"
2
4
 
3
5
  module SQLite3
@@ -58,11 +60,20 @@ module SQLite3
58
60
  # have duplicate values. See #synchronous, #default_synchronous,
59
61
  # #temp_store, and #default_temp_store for usage examples.
60
62
  def set_enum_pragma(name, mode, enums)
61
- match = enums.find { |p| p.find { |i| i.to_s.downcase == mode.to_s.downcase } }
63
+ match = if enums.is_a?(Array)
64
+ # maybe deprecate this?
65
+ enums.find { |p| p.find { |i| i.to_s.downcase == mode.to_s.downcase } }
66
+ elsif mode.is_a?(String)
67
+ enums.fetch(mode.downcase)
68
+ else
69
+ mode
70
+ end
71
+
62
72
  unless match
63
73
  raise SQLite3::Exception, "unrecognized #{name} #{mode.inspect}"
64
74
  end
65
- execute("PRAGMA #{name}='#{match.first.upcase}'")
75
+
76
+ execute("PRAGMA #{name}='#{match}'")
66
77
  end
67
78
 
68
79
  # Returns the value of the given pragma as an integer.
@@ -77,26 +88,57 @@ module SQLite3
77
88
  end
78
89
 
79
90
  # The enumeration of valid synchronous modes.
80
- SYNCHRONOUS_MODES = [["full", 2], ["normal", 1], ["off", 0]]
91
+ SYNCHRONOUS_MODES = {
92
+ "full" => 2,
93
+ "normal" => 1,
94
+ "off" => 0
95
+ }.freeze
81
96
 
82
97
  # The enumeration of valid temp store modes.
83
- TEMP_STORE_MODES = [["default", 0], ["file", 1], ["memory", 2]]
98
+ TEMP_STORE_MODES = {
99
+ "default" => 0,
100
+ "file" => 1,
101
+ "memory" => 2
102
+ }.freeze
84
103
 
85
104
  # The enumeration of valid auto vacuum modes.
86
- AUTO_VACUUM_MODES = [["none", 0], ["full", 1], ["incremental", 2]]
105
+ AUTO_VACUUM_MODES = {
106
+ "none" => 0,
107
+ "full" => 1,
108
+ "incremental" => 2
109
+ }.freeze
87
110
 
88
111
  # The list of valid journaling modes.
89
- JOURNAL_MODES = [["delete"], ["truncate"], ["persist"], ["memory"],
90
- ["wal"], ["off"]]
112
+ JOURNAL_MODES = {
113
+ "delete" => "delete",
114
+ "truncate" => "truncate",
115
+ "persist" => "persist",
116
+ "memory" => "memory",
117
+ "wal" => "wal",
118
+ "off" => "off"
119
+ }.freeze
91
120
 
92
121
  # The list of valid locking modes.
93
- LOCKING_MODES = [["normal"], ["exclusive"]]
122
+ LOCKING_MODES = {
123
+ "normal" => "normal",
124
+ "exclusive" => "exclusive"
125
+ }.freeze
94
126
 
95
127
  # The list of valid encodings.
96
- ENCODINGS = [["utf-8"], ["utf-16"], ["utf-16le"], ["utf-16be"]]
128
+ ENCODINGS = {
129
+ "utf-8" => "utf-8",
130
+ "utf-16" => "utf-16",
131
+ "utf-16le" => "utf-16le",
132
+ "utf-16be" => "utf-16be"
133
+ }.freeze
97
134
 
98
135
  # The list of valid WAL checkpoints.
99
- WAL_CHECKPOINTS = [["passive"], ["full"], ["restart"], ["truncate"]]
136
+ WAL_CHECKPOINTS = {
137
+ "passive" => "passive",
138
+ "full" => "full",
139
+ "restart" => "restart",
140
+ "truncate" => "truncate"
141
+ }.freeze
100
142
 
101
143
  def application_id
102
144
  get_int_pragma "application_id"
@@ -227,7 +269,7 @@ module SQLite3
227
269
  end
228
270
 
229
271
  def encoding=(mode)
230
- set_enum_pragma "encoding", mode, ENCODINGS
272
+ set_string_pragma "encoding", mode, ENCODINGS
231
273
  end
232
274
 
233
275
  def foreign_key_check(*table, &block) # :yields: row
@@ -295,7 +337,7 @@ module SQLite3
295
337
  end
296
338
 
297
339
  def journal_mode=(mode)
298
- set_enum_pragma "journal_mode", mode, JOURNAL_MODES
340
+ set_string_pragma "journal_mode", mode, JOURNAL_MODES
299
341
  end
300
342
 
301
343
  def journal_size_limit
@@ -319,7 +361,7 @@ module SQLite3
319
361
  end
320
362
 
321
363
  def locking_mode=(mode)
322
- set_enum_pragma "locking_mode", mode, LOCKING_MODES
364
+ set_string_pragma "locking_mode", mode, LOCKING_MODES
323
365
  end
324
366
 
325
367
  def max_page_count
@@ -525,7 +567,7 @@ module SQLite3
525
567
  end
526
568
 
527
569
  def wal_checkpoint=(mode)
528
- set_enum_pragma "wal_checkpoint", mode, WAL_CHECKPOINTS
570
+ set_string_pragma "wal_checkpoint", mode, WAL_CHECKPOINTS
529
571
  end
530
572
 
531
573
  def writable_schema=(mode)
@@ -568,6 +610,13 @@ module SQLite3
568
610
 
569
611
  private
570
612
 
613
+ def set_string_pragma(pragma_name, value, valid_values)
614
+ valid_values.fetch(value.to_s.downcase) {
615
+ raise SQLite3::Exception, "unrecognized #{pragma_name} #{value.inspect}"
616
+ }
617
+ set_enum_pragma(pragma_name, value, valid_values)
618
+ end
619
+
571
620
  # Compares two version strings
572
621
  def version_compare(v1, v2)
573
622
  v1 = v1.split(".").map { |i| i.to_i }
@@ -1,4 +1,4 @@
1
1
  module SQLite3
2
2
  # (String) the version of the sqlite3 gem, e.g. "2.1.1"
3
- VERSION = "2.6.0"
3
+ VERSION = "2.9.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlite3-ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.6.7
80
+ rubygems_version: 4.0.3
81
81
  specification_version: 4
82
82
  summary: A drop-in replacement for the sqlite3 gem for JRuby
83
83
  test_files: []