module Sequel::Plugins::InsertReturningSelect

  1. lib/sequel/plugins/insert_returning_select.rb

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

Methods

Public Class

  1. configure

Public Class methods

configure (model)

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

[show source]
# File lib/sequel/plugins/insert_returning_select.rb, line 22
def self.configure(model)
  model.instance_exec do
    self.dataset = dataset if @dataset && @dataset.opts[:select]
  end
end