bp3-core 0.7.0 → 0.7.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: b23257b58b9302540dfb2e23176bda96f7a7129bfb58b27ed15c7d0d686bda00
4
- data.tar.gz: e2aeed8779055cdbc8628a5fd5a9ddd21d13378e6a0b6a5711d2a8cf1e1d757a
3
+ metadata.gz: f2e93524b2bf6c2eda309faaa77777bf7b1c1c199564caf634a2b8253e96748f
4
+ data.tar.gz: b8939fabb44fa8b631bbc69074014b06242d55491b5b7b211330d3ecfb17b7e0
5
5
  SHA512:
6
- metadata.gz: 7f5ed8ded34381142ed75021d27f846ed3d102b9c5cd7f1cb784732eab53d6062ec5d6a752ca1c396a6c0e93cf2eb2e15efefe125235cef7bb83cb2965109b56
7
- data.tar.gz: 2458e2c43d74b91bdc31f793a27b026ed07bff3c9f2e17625c2ce95ce43446adaaec77914996f3db5e39de656efb51f83e3d2783667a45d51fcf168cd22a7fb9
6
+ metadata.gz: f898ac5bb535ca59d516fb37378450aa68d007abe0e504300dce13214d08ade4342666214ed9e1c35bf5772c30b6bfb465aed30440107b2945f34848b0259785
7
+ data.tar.gz: 7169d6b4e47aeea757d911eacaf22fd84ad1bab6a4b1920fa33e63b4dc47c527825aac3a94388f39e4430b7e8833e771789b0d9574e958907d3149de295e2767
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.1] - 2026-11-21
4
+
5
+ - Leave rqid associations out of belongs_to site check
6
+
3
7
  ## [0.7.0] - 2026-11-20
4
8
 
5
9
  - Require Ruby 4.0.10 and update Bundler to 4.1.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bp3-core (0.7.0)
4
+ bp3-core (0.7.1)
5
5
  actionview (~> 8.1)
6
6
  activesupport (~> 8.1)
7
7
  bp3-request_state (~> 0.1)
data/lib/bp3/core/rqid.rb CHANGED
@@ -7,6 +7,10 @@ module Bp3
7
7
 
8
8
  mattr_accessor :global_request_state_class_name, :global_request_state_method
9
9
 
10
+ # The records of the request a row was written in, found through the rqid they share. Sharing a
11
+ # request is not belonging to it, so Tenantable leaves them out of its site check.
12
+ REQUEST_ASSOCIATIONS = %i[original_request original_response original_visit].freeze
13
+
10
14
  def self.global_request_state_class
11
15
  global_request_state_class_name.constantize
12
16
  end
@@ -8,6 +8,10 @@ module Bp3
8
8
  # The belongs_to associations with a site check of their own
9
9
  SITE_CHECKED_ASSOCIATIONS = %i[sites_site tenant workspaces_workspace].freeze
10
10
 
11
+ # The belongs_to associations the check of the records a row belongs to passes over: those with
12
+ # a check of their own, and Rqid's, which point at the records of the request the row was written in
13
+ UNCHECKED_BELONGS_TO = (SITE_CHECKED_ASSOCIATIONS + Bp3::Core::Rqid::REQUEST_ASSOCIATIONS).freeze
14
+
11
15
  # The application's request state, the Bp3::RequestState::Base subclass Bp3::Core::Rqid is
12
16
  # configured with
13
17
  def self.global_request_state
@@ -81,7 +85,7 @@ module Bp3
81
85
  return if site_id.nil?
82
86
 
83
87
  self.class.reflect_on_all_associations(:belongs_to).each do |reflection|
84
- next if SITE_CHECKED_ASSOCIATIONS.include?(reflection.name) || !belonged_record_changed?(reflection)
88
+ next if UNCHECKED_BELONGS_TO.include?(reflection.name) || !belonged_record_changed?(reflection)
85
89
 
86
90
  belonged_site_id = belonged_record_site_id(reflection)
87
91
  next if belonged_site_id.nil? || belonged_site_id == site_id
@@ -96,7 +100,8 @@ module Bp3
96
100
  association(reflection.name).target&.new_record?
97
101
  end
98
102
 
99
- # The site of the record the association points to, nil when that record has no site
103
+ # The site of the record the association points to, nil when that record has no site. Looked up
104
+ # by the column the foreign key holds, which is the association's primary_key: when one is given.
100
105
  def belonged_record_site_id(reflection)
101
106
  loaded = association(reflection.name)
102
107
  if loaded.loaded? && !loaded.stale_target? && loaded.target
@@ -104,10 +109,10 @@ module Bp3
104
109
  end
105
110
 
106
111
  klass = belonged_record_class(reflection)
107
- id = self[reflection.foreign_key]
108
- return if klass.nil? || id.nil? || !klass.column_names.include?('sites_site_id')
112
+ key = self[reflection.foreign_key]
113
+ return if klass.nil? || key.nil? || !klass.column_names.include?('sites_site_id')
109
114
 
110
- klass.unscoped.where(klass.primary_key => id).pick(:sites_site_id)
115
+ klass.unscoped.where(reflection.association_primary_key(klass) => key).pick(:sites_site_id)
111
116
  end
112
117
 
113
118
  def belonged_record_class(reflection)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bp3
4
4
  module Core
5
- VERSION = '0.7.0'
5
+ VERSION = '0.7.1'
6
6
  end
7
7
  end
data/lib/bp3/core.rb CHANGED
@@ -10,8 +10,8 @@ require_relative 'core/feature_flags'
10
10
  require_relative 'core/ransackable'
11
11
  require_relative 'core/settings'
12
12
  require_relative 'core/system_logs'
13
- require_relative 'core/tenantable'
14
13
  require_relative 'core/rqid'
14
+ require_relative 'core/tenantable'
15
15
  require_relative 'core/sqnr'
16
16
  require_relative 'core/version'
17
17
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bp3-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wim den Braven