Module: Sequel::Plugins::ColumnSelect
- Defined in:
- lib/sequel/plugins/column_select.rb
Overview
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
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.configure(model) ⇒ Object
Modify the current model’s dataset selection, if the model has a dataset.
Class Method Details
.configure(model) ⇒ Object
Modify the current model’s dataset selection, if the model has a dataset.
28 29 30 31 32 |
# File 'lib/sequel/plugins/column_select.rb', line 28 def self.configure(model) model.instance_eval do self.dataset = dataset if @dataset end end |