Path: | doc/release_notes/4.40.0.txt |
Last Update: | Fri Oct 06 03:25:22 +0000 2017 |
Sequel.split_symbols = false
to disable the splitting of symbols. This will make Sequel no longer treat symbols with double or triple underscores as qualified or aliased identifiers, instead treating them as plain identifiers. It will also make Sequel no longer treat virtual row methods with double underscores as qualified identifiers. Examples:
# Sequel.split_symbols = true :column # "column" :table__column # "table"."column" :column___alias # "column" AS "alias" :table__column___alias # "table"."column" AS "alias" Sequel.expr{table__column} # "table"."column" # Sequel.split_symbols = false :column # "column" :table__column # "table__column" :column___alias # "column___alias" :table__column___alias # "table__column___alias" Sequel.expr{table__column} # "table__column"
Disabling symbol splitting can make things much easier if leading trailing, double, or triple underscores are used in identifiers in your database.
Disabling symbol splitting makes Sequel simpler, even if it does make it slightly less easy to create qualified and aliased identifiers. It is possible that the symbol splitting will be disabled by default starting in Sequel 5.
Note that due to Database symbol literal caching, you should not change the Sequel.split_symbols setting after creating a Database instance.
Sequel[:column].qualify(:table)
You can now use the more natural:
Sequel[:table][:column]
This can also be used in virtual rows:
Sequel.expr{table[:column]}
This offers a easy way to create qualified identifers when symbol splitting has been disabled.
:table[:column] # "table"."column"
This extension can make it easier to create qualified identifiers if symbol splitting is disabled.
A symbol_aref_refinement extension has also been added, which adds a refinement version of the extension that can be enabled via:
using Sequel::SymbolAref
:column.as(:alias) # "column" AS "alias"
This extension can make it easier to create aliased identifiers if symbol splitting is disabled.
A symbol_as_refinement extension has also been added, which adds a refinement version of the extension that can be enabled via:
using Sequel::SymbolAs
class Album < Sequel::Model extend Sequel::S one_to_many :tracks, :order=>S(:number).desc end
You can include this in Object if you want the S method to be available globally:
Object.send(:include, Sequel::S)
Sequel::S also works if it is used as a refinement, adding the S method to Object while the refinement is active:
using Sequel::S
This extension can make it easier to create qualified and aliased identifiers if symbol splitting is disabled:
S(:table)[:column] S(:column).as(:alias)
DB[:table].insert_conflict(:target=>:a, :conflict_where=>{:c=>true}).insert(:a=>1, :b=>2) # INSERT INTO TABLE (a, b) VALUES (1, 2) # ON CONFLICT (a) WHERE (c IS TRUE) DO NOTHING
Sequel.expr{column1 - (column2 - 1)}