module Sequel::Plugins::ColumnSelect

  1. lib/sequel/plugins/column_select.rb

The column_select plugin changes the default selection for a model dataset to explicit select all columns from the table: table.column1, table.column2, table.column3, .... This makes it simpler to add columns to the model’s table in a migration concurrently while running the application, without it affecting the operation of the application.

Note that by default on databases that supporting RETURNING, using explicit column selections 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 where the column_select plugin automatically sets up an explicit column selection.

Usage:

# Make all model subclasses explicitly select qualified columns
Sequel::Model.plugin :column_select

# Make the Album class select qualified columns
Album.plugin :column_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/column_select.rb
30 def self.configure(model)
31   model.instance_exec do
32     self.dataset = dataset if @dataset
33   end
34 end