Methods that turn an association that returns multiple objects into an association that returns a single object.
Methods
Public Instance
Public Instance methods
assign_singular?()
Singular associations do not assign singular if they are using the ruby eager limit strategy and have a slice range, since they need to store the array of associated objects in order to pick the correct one with an offset.
[show source]
# File lib/sequel/model/associations.rb 1152 def assign_singular? 1153 super && (eager_limit_strategy != :ruby || !slice_range) 1154 end
filter_by_associations_add_conditions?()
Add conditions when filtering by singular associations with orders, since the underlying relationship is probably not one-to-one.
[show source]
# File lib/sequel/model/associations.rb 1158 def filter_by_associations_add_conditions? 1159 super || self[:order] || self[:eager_limit_strategy] || self[:filter_limit_strategy] 1160 end
limit_and_offset()
Make sure singular associations always have 1 as the limit
[show source]
# File lib/sequel/model/associations.rb 1163 def limit_and_offset 1164 r = super 1165 if r.first == 1 1166 r 1167 else 1168 [1, r[1]] 1169 end 1170 end
returns_array?()
Singular associations always return a single object, not an array.
[show source]
# File lib/sequel/model/associations.rb 1173 def returns_array? 1174 false 1175 end