Module Sequel::Model::Associations::SingularAssociationReflection
In: lib/sequel/model/associations.rb

Methods that turn an association that returns multiple objects into an association that returns a single object.

Methods

Public Instance methods

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.

[Source]

      # File lib/sequel/model/associations.rb, line 1045
1045:         def assign_singular?
1046:           super && (eager_limit_strategy != :ruby || !slice_range)
1047:         end

Add conditions when filtering by singular associations with orders, since the underlying relationship is probably not one-to-one.

[Source]

      # File lib/sequel/model/associations.rb, line 1051
1051:         def filter_by_associations_add_conditions?
1052:           super || self[:order] || self[:eager_limit_strategy] || self[:filter_limit_strategy]
1053:         end

Make sure singular associations always have 1 as the limit

[Source]

      # File lib/sequel/model/associations.rb, line 1056
1056:         def limit_and_offset
1057:           r = super
1058:           if r.first == 1
1059:             r
1060:           else
1061:             [1, r[1]]
1062:           end
1063:         end

Singular associations always return a single object, not an array.

[Source]

      # File lib/sequel/model/associations.rb, line 1066
1066:         def returns_array?
1067:           false
1068:         end

[Validate]