Sha256: cf9067d7ca3957897f509c1edae0fe894fbbc090556f81effd0c08d92e35ac6b
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
# frozen-string-literal: true Sequel::Deprecation.deprecate("The identifier_columns plugin", "Set Sequel.split_symbols = false instead") module Sequel module Plugins # The identifier_columns plugin makes Sequel automatically # handle column names containing 2 or more consecutive # underscores when creating or updating model objects. # By default, this doesn't work correctly in Sequel, as it # handles such symbols specially. # # This behavior isn't the default as it hurts performance, # and is rarely necessary. # # Usage: # # # Make all model subclasses handle column names # # with two or more underscores when saving # Sequel::Model.plugin :identifier_columns # # # Make the Album class handle column names # # with two or more underscores when saving # Album.plugin :identifier_columns module IdentifierColumns module InstanceMethods private # Use identifiers for value hash keys when inserting. def _insert_values identifier_hash(super) end # Use identifiers for value hash keys when updating. def _update_without_checking(columns) super(identifier_hash(columns)) end # Convert the given columns hash from symbol # keys to Sequel::SQL::Identifier keys. def identifier_hash(columns) h = {} columns.each{|k,v| h[Sequel.identifier(k)] = v} h end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sequel-4.49.0 | lib/sequel/plugins/identifier_columns.rb |
sequel-4.48.0 | lib/sequel/plugins/identifier_columns.rb |