sqlite_crypto 2.2.0 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed3f34d6f260bfcbe3487f7b13489eff823b0e5d0bfc3f0459a166218b76b141
4
- data.tar.gz: 97ba38c69e755ffe3efee31d377e5e8cf056e833c41bdea26eea5f2bff5af120
3
+ metadata.gz: 5092437393d977d0bc5bd3ab75fec48c2518ff2ab0296bf6bb1abc42cdd1dfd9
4
+ data.tar.gz: 85e2ba284a68ee0cdf113895771788e5d60ee324631672f414f96756f08c5a9c
5
5
  SHA512:
6
- metadata.gz: 36e76170a44cb93f67fc21ac758b9a5513a5d372d904564198072b9bc8f578e223f5a176ad8733c525c2db40456d1944f1ecaf68cbd5ea7bf9bb3549ae1e8bfd
7
- data.tar.gz: 556b244e3c93b4b4d66f450a99d125edf20ede805b4e89831fbd21110054bab971dbf00d9a1b91a94a6891c5cb3ff1b7a01c25e60b1cc2012bb7c0254a43ae10
6
+ metadata.gz: 66a702bb87cf9ebb082a4f0a727df6fd3f8232e47295cf5d56d3e7a03d7604c29d7692ddd556753a4cf9a0e1076885273b748c65e67adede97f0cc8e44e7718e
7
+ data.tar.gz: 2d6c01a90e63dfd79947c010de863c0b0180c83056d5c72a7d9a6dd0a3e901c5ecebb6ff91c2c78c589e22a108b3183d9d382be612346ac5f3c23262fffd342d
data/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.3.0] - 2026-07-15
9
+
10
+ ### Security
11
+ - Refreshed lockfiles, picking up fixes for transitive CVEs in `sqlite3`, `nokogiri`, `json`, `crass`, and `concurrent-ruby`
12
+
13
+ ### Changed
14
+ - Updated `.ruby-version` from `4.0.3` to `4.0.6`
15
+ - CI: cache bundler installs per Rails version, run `bundler-audit` from the bundle, and drop the empty coverage-threshold step
16
+ - Narrowed the runtime dependency from `rails` to `activerecord` + `railties`, dropping the `action_text-trix` pin it required
17
+ - **Tightened ULID validation**: rejects `I`, `L`, `O`, `U`, which Crockford base32 excludes
18
+
19
+ ### Fixed
20
+ - **Reads no longer raise on malformed legacy IDs**: `Type::Base#deserialize` returns stored values as-is instead of re-validating them, so a corrupted row no longer crashes every read of it. Writes (`#cast`/`#serialize`) still validate strictly
21
+ - **Primary-key type cache invalidation**: `_sqlite_crypto_pk_type` now clears on `reset_column_information` instead of going stale after a migration
22
+ - **Adapter guard for auto ID generation**: primary-key detection now only applies to SQLite3 connections, not any string(36/26) primary key regardless of adapter
23
+ - **`references`/`belongs_to` with `to_table` and `foreign_key: true`**: the foreign key now targets the correct table instead of the pluralized association name
24
+
8
25
  ## [2.2.0] - 2026-05-08
9
26
 
10
27
  ### Added
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  <p align="center">
10
10
  <a href="https://github.com/bart-oz/sqlite_crypto/releases">
11
- <img src="https://img.shields.io/badge/version-2.2.0-blue.svg" alt="Version">
11
+ <img src="https://img.shields.io/badge/version-2.3.0-blue.svg" alt="Version">
12
12
  </a>
13
13
  <a href="LICENSE.txt">
14
14
  <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
@@ -41,7 +41,7 @@ end
41
41
  - Automatic foreign key type detection
42
42
  - Model-level ID generation
43
43
  - Clean schema.rb output
44
- - Lightweight runtime dependencies (`rails`, `sqlite3`, `ulid`)
44
+ - Lightweight runtime dependencies (`activerecord`, `railties`, `sqlite3`, `ulid` — no full `rails` metagem)
45
45
 
46
46
  ## Compatibility
47
47
 
@@ -55,8 +55,8 @@ end
55
55
  | Ruby 3.4 | ✓ | ✓ | ✓ | ✓ |
56
56
  | Ruby 4.0 | ✓ | ✓ | ✓ | ✓ |
57
57
 
58
- **Upstream lifecycle note (as of 2026-05-08):**
59
- - Ruby 3.1 is EOL; Ruby 3.2 is EOL.
58
+ **Upstream lifecycle note (as of 2026-07-15):**
59
+ - Ruby 3.1 is EOL; Ruby 3.2 is EOL. Latest stable Ruby is 4.0.6.
60
60
  - Rails 7.1 is EOL.
61
61
  - Rails 7.2 is security-fixes-only; Rails 8.0 and 8.1 are actively supported.
62
62
 
@@ -18,13 +18,19 @@ module SqliteCrypto
18
18
  module References
19
19
  def references(*args, **options)
20
20
  ref_name = args.first
21
- ref_table = options.delete(:to_table) || ref_name.to_s.pluralize
21
+ explicit_to_table = options.delete(:to_table)
22
+ ref_table = explicit_to_table || ref_name.to_s.pluralize
22
23
 
23
24
  if (primary_key_type = detect_primary_key_type(ref_table))
24
25
  options[:type] ||= :string
25
26
  options[:limit] ||= IdTypes.string_limit_for(primary_key_type)
26
27
  end
27
28
 
29
+ if explicit_to_table && options[:foreign_key]
30
+ fk_options = options[:foreign_key].is_a?(Hash) ? options[:foreign_key] : {}
31
+ options[:foreign_key] = fk_options.reverse_merge(to_table: explicit_to_table)
32
+ end
33
+
28
34
  super
29
35
  end
30
36
 
@@ -50,11 +50,17 @@ module SqliteCrypto
50
50
  @_sqlite_crypto_pk_type = _detect_sqlite_crypto_pk_type
51
51
  end
52
52
 
53
+ def reset_column_information
54
+ remove_instance_variable(:@_sqlite_crypto_pk_type) if defined?(@_sqlite_crypto_pk_type)
55
+ super
56
+ end
57
+
53
58
  private
54
59
 
55
60
  def _detect_sqlite_crypto_pk_type
56
61
  return nil if abstract_class?
57
62
  return nil unless table_exists?
63
+ return nil unless connection.adapter_name == "SQLite"
58
64
 
59
65
  pk = primary_key
60
66
  return nil unless pk
@@ -4,8 +4,7 @@ module SqliteCrypto
4
4
  module Type
5
5
  class Base < ActiveRecord::Type::String
6
6
  def deserialize(value)
7
- return if value.nil?
8
- cast(value)
7
+ value&.to_s
9
8
  end
10
9
 
11
10
  def cast(value)
@@ -25,7 +24,7 @@ module SqliteCrypto
25
24
  end
26
25
 
27
26
  def changed_in_place?(raw_old_value, new_value)
28
- cast(raw_old_value) != cast(new_value)
27
+ deserialize(raw_old_value) != cast(new_value)
29
28
  end
30
29
 
31
30
  private
@@ -5,7 +5,8 @@ require "sqlite_crypto/type/base"
5
5
  module SqliteCrypto
6
6
  module Type
7
7
  class ULID < Base
8
- ULID_PATTERN = /\A[0-7][0-9A-Z]{25}\z/i
8
+ # Crockford base32 excludes I, L, O, U to avoid confusion with 1, 0.
9
+ ULID_PATTERN = /\A[0-7][0-9A-HJKMNP-TV-Z]{25}\z/i
9
10
 
10
11
  def type
11
12
  :ulid
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SqliteCrypto
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.0"
5
5
  RUBY_MINIMUM_VERSION = "3.1.0"
6
6
  RAILS_MINIMUM_VERSION = "7.1.0"
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlite_crypto
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BartOz
@@ -10,7 +10,21 @@ cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
- name: rails
13
+ name: activerecord
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 7.1.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 7.1.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: railties
14
28
  requirement: !ruby/object:Gem::Requirement
15
29
  requirements:
16
30
  - - ">="
@@ -53,8 +67,7 @@ dependencies:
53
67
  version: '1.0'
54
68
  description: UUID and ULID primary key support for Rails with SQLite3. Provides automatic
55
69
  type registration, validation, foreign key detection, and clean schema generation.
56
- Supports UUIDv4 (random), UUIDv7 (time-ordered), and ULID (compact, time-sortable)
57
- with zero external dependencies.
70
+ Supports UUIDv4 (random), UUIDv7 (time-ordered), and ULID (compact, time-sortable).
58
71
  email:
59
72
  - bartek.ozdoba@gmail.com
60
73
  executables: []
@@ -99,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
112
  - !ruby/object:Gem::Version
100
113
  version: '0'
101
114
  requirements: []
102
- rubygems_version: 4.0.6
115
+ rubygems_version: 4.0.16
103
116
  specification_version: 4
104
117
  summary: UUID (v4/v7) and ULID primary keys for Rails + SQLite3
105
118
  test_files: []