paquito 0.11.3 → 1.0.1

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: 5ede4c0254b56d0c34d1d664903ffcd51db1ce717723a82858973c76d41231bb
4
- data.tar.gz: 97d7ac64e05043df851dd6ef49cec163991c91afc6b25e98e1b4649a5a808eb8
3
+ metadata.gz: 39298f47e19e7301c919b1a36c7a6a54b22da82752f6490dd50cfaf178979c61
4
+ data.tar.gz: f2bb86111a2f54fd5bface1f43fb54ec15c25b2c03ade4a667823188b1464341
5
5
  SHA512:
6
- metadata.gz: 650bc85b15bbf5c2516941222d3de02e6c7b622a0998e9ccd2db2adf439964d5edc877227b750fad06903c0d00f58a61004e3e6271b37bf6d67f8a1aeb45dcfc
7
- data.tar.gz: b2b03a2c958c622e68b8f1cf3745d89b4cefc9ac4070875d85174ed3c5943c27a31df049f44b677d9fd6c33e958c8ddc9b834f4d8870ed8a547fe7b30b1df8ba
6
+ metadata.gz: 5391e5db6c0c4094a060d2dd61b561830cfc7696e3f926d5b209acc95df97101428cdcf2159b2ffe3c5c9ea1943fbdf43c0ef15f84f2b19edcb0fc12501a127a
7
+ data.tar.gz: 4004e18dc637b1febc9b4607562dca2d0317b6867f3cb9826c1354151bb1f012377fec5c0a2cde9a170c1fa6c9c3f9cfe948bbb9b740dd9912726d8a607278db
@@ -0,0 +1,29 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v[0-9]+.[0-9]+.[0-9]+
7
+
8
+ jobs:
9
+ release:
10
+ if: github.repository == 'Shopify/paquito'
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ permissions:
15
+ contents: write
16
+ id-token: write
17
+
18
+ environment: release
19
+
20
+ steps:
21
+ - uses: actions/checkout@v6
22
+ with:
23
+ persist-credentials: false
24
+
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ bundler-cache: true
28
+
29
+ - uses: rubygems/release-gem@v1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
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
+
1
15
  # 0.11.3
2
16
 
3
17
  * Deserialize records with extra unused array elements in payload (#52)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paquito (0.11.3)
4
+ paquito (1.0.1)
5
5
  msgpack (>= 1.5.2)
6
6
 
7
7
  GEM
@@ -34,7 +34,7 @@ GEM
34
34
  drb (2.2.1)
35
35
  i18n (1.14.5)
36
36
  concurrent-ruby (~> 1.0)
37
- json (2.7.1)
37
+ json (2.11.3)
38
38
  language_server-protocol (3.17.0.3)
39
39
  logger (1.6.0)
40
40
  mini_portile2 (2.8.8)
@@ -46,7 +46,7 @@ GEM
46
46
  racc
47
47
  racc (1.7.3)
48
48
  rainbow (3.1.1)
49
- rake (13.0.6)
49
+ rake (13.2.1)
50
50
  regexp_parser (2.9.0)
51
51
  rexml (3.3.9)
52
52
  rubocop (1.62.1)
@@ -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,32 @@ 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 = +""
125
+ klass.columns_hash.each do |name, column|
126
+ str << "," unless str.empty?
127
+ str << name << ":" << column.sql_type
128
+ end
129
+ ::Digest::MD5.digest(str).unpack1("s")
130
+ end
114
131
  end
115
132
 
116
133
  class Error < ::Paquito::Error
@@ -122,6 +139,9 @@ module Paquito
122
139
  class AssociationMissingError < Error
123
140
  end
124
141
 
142
+ class ColumnsDigestMismatch < Error
143
+ end
144
+
125
145
  class InstanceTracker
126
146
  def initialize
127
147
  @instances = []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paquito
4
- VERSION = "0.11.3"
4
+ VERSION = "1.0.1"
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,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paquito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-06 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: msgpack
@@ -34,6 +34,7 @@ files:
34
34
  - ".devcontainer/devcontainer.json"
35
35
  - ".github/workflows/ci.yml"
36
36
  - ".github/workflows/cla.yml"
37
+ - ".github/workflows/release.yml"
37
38
  - ".gitignore"
38
39
  - ".rubocop.yml"
39
40
  - ".ruby-version"
@@ -82,6 +83,12 @@ metadata:
82
83
  allowed_push_host: https://rubygems.org
83
84
  homepage_uri: https://github.com/Shopify/paquito
84
85
  source_code_uri: https://github.com/Shopify/paquito
86
+ post_install_message: |
87
+ Warning: Paquito 1.0 includes potentially breaking changes to ActiveRecordCoder.
88
+ Before upgrading to 1.0 from an earlier version, ensure you have first upgraded
89
+ to 0.11.3 and deployed your application before upgrading to 1.0. Also ensure you
90
+ rescue either all `ActiveRecordCoder::Error` errors, or that you explicitly
91
+ rescue the new `ActiveRecord::ColumnsDigestError`.
85
92
  rdoc_options: []
86
93
  require_paths:
87
94
  - lib
@@ -96,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
103
  - !ruby/object:Gem::Version
97
104
  version: '0'
98
105
  requirements: []
99
- rubygems_version: 3.6.3
106
+ rubygems_version: 4.0.6
100
107
  specification_version: 4
101
108
  summary: Framework for defining efficient and extendable serializers
102
109
  test_files: []