Skip to content

Commit eec6c23

Browse files
committed
Add strict_loading_by_default by default compatibility
Fixes rails#122 Allow an app to run in strict_loading_by_default mode by explicitly turning off strict loading on all solid queue models.
1 parent 51c75be commit eec6c23

File tree

9 files changed

+12
-10
lines changed

9 files changed

+12
-10
lines changed

app/models/solid_queue/claimed_execution.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
class SolidQueue::ClaimedExecution < SolidQueue::Execution
4-
belongs_to :process
4+
belongs_to :process, strict_loading: false
55

66
scope :orphaned, -> { where.missing(:process) }
77

app/models/solid_queue/execution.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class UndiscardableError < StandardError; end
1010

1111
scope :ordered, -> { order(priority: :asc, job_id: :asc) }
1212

13-
belongs_to :job
13+
belongs_to :job, strict_loading: false
1414

1515
class << self
1616
def type

app/models/solid_queue/job/concurrency_controls.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module ConcurrencyControls
66
extend ActiveSupport::Concern
77

88
included do
9-
has_one :blocked_execution
9+
has_one :blocked_execution, strict_loading: false
1010

1111
delegate :concurrency_limit, :concurrency_duration, to: :job_class
1212

app/models/solid_queue/job/executable.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module Executable
88
included do
99
include ConcurrencyControls, Schedulable, Retryable
1010

11-
has_one :ready_execution
12-
has_one :claimed_execution
11+
has_one :ready_execution, strict_loading: false
12+
has_one :claimed_execution, strict_loading: false
1313

1414
after_create :prepare_for_execution
1515

app/models/solid_queue/job/recurrable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Recurrable
66
extend ActiveSupport::Concern
77

88
included do
9-
has_one :recurring_execution, dependent: :destroy
9+
has_one :recurring_execution, strict_loading: false, dependent: :destroy
1010
end
1111
end
1212
end

app/models/solid_queue/job/retryable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Retryable
66
extend ActiveSupport::Concern
77

88
included do
9-
has_one :failed_execution
9+
has_one :failed_execution, strict_loading: false
1010

1111
scope :failed, -> { includes(:failed_execution).where.not(failed_execution: { id: nil }) }
1212
end

app/models/solid_queue/job/schedulable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Schedulable
66
extend ActiveSupport::Concern
77

88
included do
9-
has_one :scheduled_execution
9+
has_one :scheduled_execution, strict_loading: false
1010

1111
scope :scheduled, -> { where(finished_at: nil) }
1212
end

app/models/solid_queue/process.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
class SolidQueue::Process < SolidQueue::Record
44
include Executor, Prunable
55

6-
belongs_to :supervisor, class_name: "SolidQueue::Process", optional: true, inverse_of: :supervisees
7-
has_many :supervisees, class_name: "SolidQueue::Process", inverse_of: :supervisor, foreign_key: :supervisor_id
6+
belongs_to :supervisor, class_name: "SolidQueue::Process", optional: true, inverse_of: :supervisees, strict_loading: false
7+
has_many :supervisees, class_name: "SolidQueue::Process", inverse_of: :supervisor, foreign_key: :supervisor_id, strict_loading: false
88

99
store :metadata, coder: JSON
1010

test/dummy/config/application.rb

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class Application < Rails::Application
2929

3030
config.active_job.queue_adapter = :solid_queue
3131

32+
config.active_record.strict_loading_by_default = true
33+
3234
if ENV["SEPARATE_CONNECTION"] && ENV["TARGET_DB"] != "sqlite"
3335
config.solid_queue.connects_to = { database: { writing: :primary, reading: :replica } }
3436
end

0 commit comments

Comments
 (0)