Sha256: a18abca295ad1ba05fecf70785e81315a8a9dbd758276cc12c418b04d73617be

Contents?: true

Size: 911 Bytes

Versions: 21

Compression:

Stored size: 911 Bytes

Contents

# frozen-string-literal: true

module Sequel
  class Dataset
    module Replace
      INSERT = Dataset::INSERT
      REPLACE = 'REPLACE'.freeze

      # Execute a REPLACE statement on the database (deletes any duplicate
      # rows before inserting).
      def replace(*values)
        execute_insert(replace_sql(*values))
      end

      # SQL statement for REPLACE
      def replace_sql(*values)
        clone(:replace=>true).insert_sql(*values)
      end

      # Replace multiple rows in a single query.
      def multi_replace(*values)
        clone(:replace=>true).multi_insert(*values)
      end

      # Databases using this module support REPLACE.
      def supports_replace?
        true
      end

      private

      # If this is an replace instead of an insert, use replace instead
      def insert_insert_sql(sql)
        sql << (@opts[:replace] ? REPLACE : INSERT)
      end
    end
  end
end

Version data entries

21 entries across 20 versions & 2 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/sequel-4.44.0/lib/sequel/adapters/utils/replace.rb
tdiary-5.0.5 vendor/bundle/gems/sequel-4.44.0/lib/sequel/adapters/utils/replace.rb
sequel-4.45.0 lib/sequel/adapters/utils/replace.rb
tdiary-5.0.4 vendor/bundle/gems/sequel-4.44.0/lib/sequel/adapters/utils/replace.rb
sequel-4.44.0 lib/sequel/adapters/utils/replace.rb
sequel-4.43.0 lib/sequel/adapters/utils/replace.rb
sequel-4.42.1 lib/sequel/adapters/utils/replace.rb
sequel-4.42.0 lib/sequel/adapters/utils/replace.rb
sequel-4.41.0 lib/sequel/adapters/utils/replace.rb
sequel-4.40.0 lib/sequel/adapters/utils/replace.rb
sequel-4.39.0 lib/sequel/adapters/utils/replace.rb
tdiary-5.0.2 vendor/bundle/gems/sequel-4.37.0/lib/sequel/adapters/utils/replace.rb
sequel-4.38.0 lib/sequel/adapters/utils/replace.rb
sequel-4.37.0 lib/sequel/adapters/utils/replace.rb
sequel-4.36.0 lib/sequel/adapters/utils/replace.rb
tdiary-5.0.1 vendor/bundle/gems/sequel-4.35.0/lib/sequel/adapters/utils/replace.rb
sequel-4.35.0 lib/sequel/adapters/utils/replace.rb
sequel-4.34.0 lib/sequel/adapters/utils/replace.rb
sequel-4.33.0 lib/sequel/adapters/utils/replace.rb
sequel-4.32.0 lib/sequel/adapters/utils/replace.rb