Skip to content

Commit

Permalink
Support explicitly specifying :use_placeholder_loader association option
Browse files Browse the repository at this point in the history
In general, this should only be explicitly set to false to disable the
use of the loader (useful for easier testing), it should not be
explicitly set to true.
  • Loading branch information
jeremyevans committed Feb 3, 2025
1 parent fca060d commit 0a728fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
=== master

* Support explicitly specifying :use_placeholder_loader association option (jeremyevans)

* Make SQL::BooleanExpression.from_value_pairs handle Dataset::PlaceholderLiteralizer::Argument with existing transformer correctly (jeremyevans)

* Make connection_validator extension not swallow exceptions raised by Database#valid_connection? (jeremyevans)
Expand Down
5 changes: 4 additions & 1 deletion lib/sequel/model/associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,9 @@ def all_association_reflections
# Set to nil to not define a setter method for the association.
# :subqueries_per_union :: The number of subqueries to use in each UNION query, for eager
# loading limited associations using the default :union strategy.
# :use_placeholder_loader :: Whether to use a placeholder loader when eager loading the
# association. Can be set to false to disable the use of a placeholder
# loader if one would be used by default.
# :validate :: Set to false to not validate when implicitly saving any associated object.
# === :many_to_one
# :key :: foreign key in current model's table that references
Expand Down Expand Up @@ -1891,7 +1894,7 @@ def associate(type, name, opts = OPTS, &block)
raise(Error, "cannot clone an association to an association of different type (association #{name} with type #{type} cloning #{opts[:clone]} with type #{cloned_assoc[:type]})")
end

opts[:use_placeholder_loader] = !opts[:instance_specific] && !opts[:eager_graph]
opts[:use_placeholder_loader] = !opts[:instance_specific] && !opts[:eager_graph] unless opts.include?(:use_placeholder_loader)
opts[:eager_block] = opts[:block] unless opts.include?(:eager_block)
opts[:graph_join_type] ||= :left_outer
opts[:order_eager_graph] = true unless opts.include?(:order_eager_graph)
Expand Down

0 comments on commit 0a728fd

Please sign in to comment.