module Sequel::Plugins::TableSelect

  1. lib/sequel/plugins/table_select.rb

The table_select plugin changes the default selection for a model dataset from * to table.*. This makes it so that if you join the model’s dataset to other tables, columns in the other tables do not appear in the result sets (and possibly overwrite columns in the current model with the same name).

Note that by default on databases that supporting RETURNING, using this plugin will cause instance creations to use two queries (insert and refresh) instead of a single query using RETURNING. You can use the insert_returning_select plugin to automatically use RETURNING for instance creations for models using this plugin.

Usage:

# Make all model subclasses select table.*
Sequel::Model.plugin :table_select

# Make the Album class select albums.*
Album.plugin :table_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/table_select.rb
29 def self.configure(model)
30   model.instance_exec do
31     self.dataset = dataset if @dataset
32   end
33 end