Module: Sequel::Plugins::InsertReturningSelect

Defined in:
lib/sequel/plugins/insert_returning_select.rb

Overview

If the model’s dataset selects explicit columns and the database supports it, the insert_returning_select plugin will automatically set the RETURNING clause on the dataset used to insert rows to the columns selected, which allows the default model support to run the insert and refresh of the data in a single query, instead of two separate queries. This is Sequel’s default behavior when the model does not select explicit columns.

Usage:

# Make all model subclasses automatically setup insert returning clauses
Sequel::Model.plugin :insert_returning_select

# Make the Album class automatically setup insert returning clauses
Album.plugin :insert_returning_select

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.configure(model) ⇒ Object

Modify the current model’s dataset selection, if the model has a dataset.



23
24
25
26
27
# File 'lib/sequel/plugins/insert_returning_select.rb', line 23

def self.configure(model)
  model.instance_eval do
    self.dataset = dataset if @dataset && @dataset.opts[:select]
  end
end