Module: Torque::PostgreSQL::Relation::Initializer

Includes:
Buckets::Initializer
Included in:
ActiveRecord::Relation
Defined in:
lib/torque/postgresql/relation.rb,
sig/torque/postgresql/relation.rbs,
sig/torque/postgresql/relation/buckets.rbs

Overview

When a relation is created, force the attributes to be defined, because the type mapper may add new methods to the model. This happens for the given model Klass and its inheritances

Instance Method Summary collapse

Methods included from Buckets::Initializer

#records

Instance Method Details

#initialize(klass) ⇒ Initializer

Returns a new instance of Initializer.

Parameters:

  • klass (model)
  • (Object)
  • (Object)

Returns:



140
141
142
143
144
145
# File 'lib/torque/postgresql/relation.rb', line 140

def initialize(klass, *, **)
  super

  klass.superclass.send(:relation) if klass.define_attribute_methods &&
    klass.superclass != ActiveRecord::Base && !klass.superclass.abstract_class?
end

#upsert_all(attributes, **xargs) ⇒ Object

Allow extra keyword arguments to be sent to InsertAll

Parameters:

  • attributes (Array[Hash[column_ref, untyped]])
  • where: (String, relation, nil)
  • xargs (Object)

Returns:

  • (Object)


148
149
150
151
# File 'lib/torque/postgresql/relation.rb', line 148

def upsert_all(attributes, **xargs)
  xargs = xargs.reverse_merge(on_duplicate: :update)
  ::ActiveRecord::InsertAll.execute(self, attributes, **xargs)
end