paquito 0.11.2 → 1.0.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: c17414fe5eb86f48716aba9c725c46366b93f55dc5995c835cd37e67d4497407
4
- data.tar.gz: 56998f2dbe8154770b95baf199fa1c4e784c5463d85350537407d9786aa85aeb
3
+ metadata.gz: 6b6c5c9838f1a54d3ffce2095ac8b46b423b54eaea4704ace9e7a33ad011316d
4
+ data.tar.gz: e3b26fc6ecdc8ad279b2f9157089536d69e942fe011458b521da0daf2b8e423d
5
5
  SHA512:
6
- metadata.gz: 6b6d275659c0714a06ec387799c15d0011a8e568530c16a7719b187d314a47ec8b8b91a19d131e1c5adb182bccf7f591a41b2f19032fdda416be93584aaaed9a
7
- data.tar.gz: 9ae37989ccbad977917fd0528c023f73fd56b4ba160058d6ab90b9fbeeb5db8dd4cf3d1eded1d976c92c3ffa666a7e6397a519deda464fb15f231f6d1f9141b0
6
+ metadata.gz: 513b52e62ba30a9f3f94f63b19b467f9c9dbed9ec3a65d41dd9efe8a50a97bbf580c8c3c29a6dd15a2f4ace5e4f692728377757983d6500ef3b531db83c955e8
7
+ data.tar.gz: 90b2dffe3fe1569ee79927e7aecead29731665908b03772c300e95bab2e62844fc2a247b4b54da5ab1999c0608fa8bb7606990b1d18777779bf651ada1fd14eb
@@ -0,0 +1,7 @@
1
+ # Make sure RUBY_VERSION matches the Ruby version in .ruby-version
2
+ ARG RUBY_VERSION=3.4.1
3
+ FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION
4
+
5
+ RUN apt-get update && apt-get install -y \
6
+ libsqlite3-dev \
7
+ pkg-config
@@ -0,0 +1,25 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3
+ {
4
+ "name": "Ruby",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ "dockerFile": "Dockerfile",
7
+ "features": {
8
+ "ghcr.io/devcontainers/features/github-cli:1": {}
9
+ }
10
+
11
+ // Features to add to the dev container. More info: https://containers.dev/features.
12
+ // "features": {},
13
+
14
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
15
+ // "forwardPorts": [],
16
+
17
+ // Use 'postCreateCommand' to run commands after the container is created.
18
+ // "postCreateCommand": "ruby --version",
19
+
20
+ // Configure tool-specific properties.
21
+ // "customizations": {},
22
+
23
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
24
+ // "remoteUser": "root"
25
+ }
@@ -29,25 +29,29 @@ jobs:
29
29
  - name: Set up Ruby
30
30
  uses: ruby/setup-ruby@v1
31
31
  with:
32
- ruby-version: '3.3'
32
+ ruby-version: '3.4'
33
33
  bundler-cache: true
34
34
 
35
35
  - name: Install gem
36
36
  run: bundle exec rake install
37
-
37
+
38
38
 
39
39
  rubies:
40
40
  runs-on: ubuntu-latest
41
41
  strategy:
42
42
  fail-fast: false
43
43
  matrix:
44
- ruby: [ ruby-head, '3.3', '3.2', '3.1']
45
- rails: [ '7.2', '7.1']
44
+ ruby: [ ruby-head, '3.4', '3.3', '3.2']
45
+ rails: [ '8.0', '7.2', '7.1']
46
46
  include:
47
47
  - ruby: '2.7'
48
48
  rails: '7.1'
49
49
  - ruby: '3.0'
50
50
  rails: '7.1'
51
+ - ruby: '3.1'
52
+ rails: '7.1'
53
+ - ruby: '3.1'
54
+ rails: '7.2'
51
55
  env:
52
56
  BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails }}.gemfile
53
57
  steps:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.4.1
data/CHANGELOG.md CHANGED
@@ -1,4 +1,20 @@
1
- # Unreleased
1
+ # 1.0.0
2
+
3
+ Both changes in this release require applications to be fully updated to the latest patch version of the gem before
4
+ bumping to this version.
5
+
6
+ * Store md5 digest of columns + sql types along with records (#51)
7
+ *IMPORTANT*: if you are storing Active Record objects in the cache, ensure you have updated and deployed 0.11.3 before
8
+ upgrading, and ensure you are handling either all `ActiveRecordCoder::Error` errors, or that you explicitly add
9
+ `ActiveRecordCoder::ColumnsDigestMismatch` to your error handling.
10
+ * Bump `Paquito.format_version` to `1` by default.
11
+ *IMPORTANT*: if you are upgrading from a previous version, you MUST first fully deploy the gem up to at least version 0.10.0
12
+ and release before enabling it. If you don't, you may notice some `UnpackError` during the code rollout, which may be fine
13
+ if you only use Paquito for ephemeral cache data. See release notes for v0.10.0.
14
+
15
+ # 0.11.3
16
+
17
+ * Deserialize records with extra unused array elements in payload (#52)
2
18
 
3
19
  # 0.11.2
4
20
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paquito (0.11.2)
4
+ paquito (1.0.0)
5
5
  msgpack (>= 1.5.2)
6
6
 
7
7
  GEM
@@ -37,6 +37,7 @@ GEM
37
37
  json (2.7.1)
38
38
  language_server-protocol (3.17.0.3)
39
39
  logger (1.6.0)
40
+ mini_portile2 (2.8.8)
40
41
  minitest (5.25.1)
41
42
  msgpack (1.7.2)
42
43
  parallel (1.24.0)
@@ -47,8 +48,7 @@ GEM
47
48
  rainbow (3.1.1)
48
49
  rake (13.0.6)
49
50
  regexp_parser (2.9.0)
50
- rexml (3.3.6)
51
- strscan
51
+ rexml (3.3.9)
52
52
  rubocop (1.62.1)
53
53
  json (~> 2.3)
54
54
  language_server-protocol (>= 3.17.0)
@@ -66,16 +66,16 @@ GEM
66
66
  rubocop (~> 1.44)
67
67
  ruby-progressbar (1.13.0)
68
68
  securerandom (0.3.1)
69
- sorbet-runtime (0.5.10712)
70
- sqlite3 (2.0.4-arm64-darwin)
71
- sqlite3 (2.0.4-x86_64-linux-gnu)
72
- strscan (3.1.0)
69
+ sorbet-runtime (0.5.11633)
70
+ sqlite3 (2.0.4)
71
+ mini_portile2 (~> 2.8.0)
73
72
  timeout (0.4.1)
74
73
  tzinfo (2.0.6)
75
74
  concurrent-ruby (~> 1.0)
76
75
  unicode-display_width (2.5.0)
77
76
 
78
77
  PLATFORMS
78
+ aarch64-linux
79
79
  arm64-darwin
80
80
  x86_64-linux
81
81
 
@@ -93,4 +93,4 @@ DEPENDENCIES
93
93
  sqlite3
94
94
 
95
95
  BUNDLED WITH
96
- 2.5.7
96
+ 2.6.3
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "msgpack", ">= 1.5.2"
6
+
7
+ gem "rake", "~> 13.0"
8
+ gem "activesupport", "~> 8.0.0"
9
+ gem "activerecord", "~> 8.0.0"
10
+ gem "sqlite3"
11
+ gem "benchmark-ips"
12
+
13
+ gem "minitest", "~> 5.0"
14
+
15
+ gem "rubocop"
16
+ gem "rubocop-shopify", "~> 2.0", require: false
17
+ gem "byebug"
18
+
19
+ gem "sorbet-runtime"
@@ -88,9 +88,12 @@ module Paquito
88
88
  end
89
89
 
90
90
  def serialize_record(record)
91
- arguments = [record.class.name, attributes_for_database(record)]
92
- arguments << true if record.new_record?
93
- arguments
91
+ [
92
+ record.class.name,
93
+ attributes_for_database(record),
94
+ record.new_record?,
95
+ columns_digest(record.class),
96
+ ]
94
97
  end
95
98
 
96
99
  def attributes_for_database(record)
@@ -99,18 +102,28 @@ module Paquito
99
102
  attributes
100
103
  end
101
104
 
102
- def deserialize_record(class_name, attributes_from_database, new_record = false)
105
+ def deserialize_record(class_name, attributes_from_database, new_record = false, hash = nil, *)
103
106
  begin
104
107
  klass = Object.const_get(class_name)
105
108
  rescue NameError
106
109
  raise ClassMissingError, "undefined class: #{class_name}"
107
110
  end
108
111
 
112
+ if hash && (hash != (expected_digest = columns_digest(klass)))
113
+ raise ColumnsDigestMismatch,
114
+ "\"#{hash}\" does not match the expected digest of \"#{expected_digest}\""
115
+ end
116
+
109
117
  # Ideally we'd like to call `klass.instantiate`, however it doesn't allow to pass
110
118
  # wether the record was persisted or not.
111
119
  attributes = klass.attributes_builder.build_from_database(attributes_from_database, EMPTY_HASH)
112
120
  klass.allocate.init_with_attributes(attributes, new_record)
113
121
  end
122
+
123
+ def columns_digest(klass)
124
+ str = klass.columns_hash.map { |name, column| [name, column.sql_type].join(":") }.join(",")
125
+ ::Digest::MD5.digest(str).unpack1("s")
126
+ end
114
127
  end
115
128
 
116
129
  class Error < ::Paquito::Error
@@ -122,6 +135,9 @@ module Paquito
122
135
  class AssociationMissingError < Error
123
136
  end
124
137
 
138
+ class ColumnsDigestMismatch < Error
139
+ end
140
+
125
141
  class InstanceTracker
126
142
  def initialize
127
143
  @instances = []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paquito
4
- VERSION = "0.11.2"
4
+ VERSION = "1.0.0"
5
5
  end
data/lib/paquito.rb CHANGED
@@ -29,7 +29,7 @@ module Paquito
29
29
  autoload :FlatCacheEntryCoder, "paquito/flat_cache_entry_coder"
30
30
  autoload :ActiveRecordCoder, "paquito/active_record_coder"
31
31
 
32
- DEFAULT_FORMAT_VERSION = 0
32
+ DEFAULT_FORMAT_VERSION = 1
33
33
  @format_version = DEFAULT_FORMAT_VERSION
34
34
 
35
35
  class << self
data/paquito.gemspec CHANGED
@@ -19,6 +19,14 @@ Gem::Specification.new do |spec|
19
19
  spec.metadata["homepage_uri"] = spec.homepage
20
20
  spec.metadata["source_code_uri"] = "https://github.com/Shopify/paquito"
21
21
 
22
+ spec.post_install_message = <<~POST_INSTALL_MSG
23
+ Warning: Paquito 1.0 includes potentially breaking changes to ActiveRecordCoder.
24
+ Before upgrading to 1.0 from an earlier version, ensure you have first upgraded
25
+ to 0.11.3 and deployed your application before upgrading to 1.0. Also ensure you
26
+ rescue either all `ActiveRecordCoder::Error` errors, or that you explicitly
27
+ rescue the new `ActiveRecord::ColumnsDigestError`.
28
+ POST_INSTALL_MSG
29
+
22
30
  # Specify which files should be added to the gem when it is released.
23
31
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
32
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paquito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-10-17 00:00:00.000000000 Z
10
+ date: 2025-02-25 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: msgpack
@@ -31,6 +30,8 @@ executables: []
31
30
  extensions: []
32
31
  extra_rdoc_files: []
33
32
  files:
33
+ - ".devcontainer/Dockerfile"
34
+ - ".devcontainer/devcontainer.json"
34
35
  - ".github/workflows/ci.yml"
35
36
  - ".github/workflows/cla.yml"
36
37
  - ".gitignore"
@@ -50,6 +51,7 @@ files:
50
51
  - dev.yml
51
52
  - gemfiles/rails_7.1.gemfile
52
53
  - gemfiles/rails_7.2.gemfile
54
+ - gemfiles/rails_8.0.gemfile
53
55
  - lib/paquito.rb
54
56
  - lib/paquito/active_record_coder.rb
55
57
  - lib/paquito/allow_nil.rb
@@ -80,7 +82,12 @@ metadata:
80
82
  allowed_push_host: https://rubygems.org
81
83
  homepage_uri: https://github.com/Shopify/paquito
82
84
  source_code_uri: https://github.com/Shopify/paquito
83
- post_install_message:
85
+ post_install_message: |
86
+ Warning: Paquito 1.0 includes potentially breaking changes to ActiveRecordCoder.
87
+ Before upgrading to 1.0 from an earlier version, ensure you have first upgraded
88
+ to 0.11.3 and deployed your application before upgrading to 1.0. Also ensure you
89
+ rescue either all `ActiveRecordCoder::Error` errors, or that you explicitly
90
+ rescue the new `ActiveRecord::ColumnsDigestError`.
84
91
  rdoc_options: []
85
92
  require_paths:
86
93
  - lib
@@ -95,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
102
  - !ruby/object:Gem::Version
96
103
  version: '0'
97
104
  requirements: []
98
- rubygems_version: 3.5.21
99
- signing_key:
105
+ rubygems_version: 3.6.3
100
106
  specification_version: 4
101
107
  summary: Framework for defining efficient and extendable serializers
102
108
  test_files: []