rubydb 0.1.2 → 0.1.3

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: 5cfc85dc4d3cfca89bd7d89335e4bf887fbfca212836f8a62d92a70a63f0f284
4
- data.tar.gz: 9869f03b9da1a7e0cfd0c01f1f22ae9b5ba0e2b12eedaeac72e1b4deab878a0b
3
+ metadata.gz: 3c076e3acf3d8cf15a98581eb92daafdbe2aba8a40805279c08c957aece8a601
4
+ data.tar.gz: 36eeb2c1ea39757ee1c759af4f1abefea987ba28f0929642258f289c3196df66
5
5
  SHA512:
6
- metadata.gz: 76650c2403e26244619687eb6146bb7a1561d3764d664094a6deb94e02566924c60979f481aca972be026987775f8c9b68ed02804d15e583f885528e02833613
7
- data.tar.gz: 60c894fde163c1a47ed84aa2c2d8b374a9b6c70f3d810feb7ca419a06aa2cb5e6026d8aa278d27ed89ad4a83b48405c31137671f1d2dab7240d0efc36b367de8
6
+ metadata.gz: 358853343b4781a04e72e1e9910ed4c8fe562f4e56a9d3b2c27bb6b962da78bc3eeabfca4efbfa3b83c8e8d0f3295b368701b38fbc2baab361109bfe173ca3b8
7
+ data.tar.gz: a0a90a0cd04781b3dd35bbd94a46513debdf69195e09fadd677d21d27b005db874d048b8281d432f68350f86f21c64ceb39b24fa4ae17ee6903034782ca8dc4a
data/CHANGELOG.md CHANGED
@@ -23,6 +23,13 @@ All notable changes to RubyDB are documented here. Versions follow
23
23
  vacuum, maintenance, and release workflows.
24
24
  - Clarified the tested common SQLite-style profile and production limits.
25
25
 
26
+ ## 0.1.3 - 2026-09-09
27
+
28
+ - Normalized numeric MVCC visibility-map keys after restart to prevent mixed
29
+ string/integer keys and duplicate-key warnings on Ruby 4.
30
+ - Made visibility-map persistence failures raise `RubyDB::StorageError`
31
+ instead of silently reporting success.
32
+
26
33
  ## 0.1.2 - 2026-09-09
27
34
 
28
35
  - Added SQLite/ActiveRecord-compatible `INSERT ... DEFAULT VALUES` parsing,
@@ -686,11 +686,13 @@ module RubyDB
686
686
  end
687
687
  end
688
688
 
689
- @active_transactions = parsed[:active_transactions] || {}
690
- @committed_transactions = Set.new(parsed[:committed_transactions] || [])
691
- @aborted_transactions = Set.new(parsed[:aborted_transactions] || [])
692
- @next_version_id = parsed[:next_version_id] || 1
693
- @row_version_chains = parsed[:row_version_chains] || {}
689
+ @active_transactions = normalize_numeric_keyed_hash(parsed[:active_transactions])
690
+ @committed_transactions = Set.new(parsed[:committed_transactions] || [])
691
+ @aborted_transactions = Set.new(parsed[:aborted_transactions] || [])
692
+ @next_version_id = parsed[:next_version_id] || 1
693
+ @row_version_chains = normalize_numeric_keyed_hash(parsed[:row_version_chains]) do |versions|
694
+ Array(versions).map(&:to_i)
695
+ end
694
696
 
695
697
  # Clean up any invalid data
696
698
  @active_transactions.each do |tx_id, info|
@@ -727,24 +729,35 @@ module RubyDB
727
729
 
728
730
  # Write to a temp file first, then rename
729
731
  temp_path = "#{visibility_path}.tmp"
730
- File.write(temp_path, JSON.generate(data))
731
- FileUtils.mv(temp_path, visibility_path)
732
-
733
- true
734
- rescue => e
735
- false
736
- end
737
- end
738
- end
732
+ File.write(temp_path, JSON.generate(data))
733
+ FileUtils.mv(temp_path, visibility_path)
734
+
735
+ true
736
+ rescue => e
737
+ File.delete(temp_path) if defined?(temp_path) && File.file?(temp_path)
738
+ raise StorageError, "Failed to flush visibility map: #{e.message}"
739
+ end
740
+ end
741
+ end
739
742
 
740
743
  # Remove a row from disk storage
741
744
  def remove_row_from_disk(row_id)
742
745
  true
743
746
  end
744
747
 
745
- def remember_version(row_id, info)
746
- @version_history[row_id][info[:version].to_i] = info.dup
747
- end
748
+ def remember_version(row_id, info)
749
+ @version_history[row_id][info[:version].to_i] = info.dup
750
+ end
751
+
752
+ # JSON object keys are strings. Normalize numeric-keyed runtime maps on
753
+ # load so a reopened database cannot accumulate both "1" and 1 keys.
754
+ def normalize_numeric_keyed_hash(value)
755
+ normalized = {}
756
+ (value || {}).each do |key, entry|
757
+ normalized[key.to_s.to_i] = block_given? ? yield(entry) : entry
758
+ end
759
+ normalized
760
+ end
748
761
 
749
762
  def normalize_loaded_info(info)
750
763
  info.each_with_object({}) do |(key, value), normalized|
@@ -11,13 +11,13 @@ module RubyDB
11
11
  # - MAJOR: Incompatible API changes
12
12
  # - MINOR: Backwards-compatible new functionality
13
13
  # - PATCH: Backwards-compatible bug fixes
14
- VERSION = "0.1.2"
14
+ VERSION = "0.1.3"
15
15
 
16
16
  # Version components for easy access
17
17
  module Version
18
18
  MAJOR = 0
19
19
  MINOR = 1
20
- PATCH = 2
20
+ PATCH = 3
21
21
  PRE = nil # e.g., "alpha", "beta", "rc1"
22
22
 
23
23
  def self.to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldane Hutchinson