Sha256: 09bdeab8a03d4ba4266db497e1eabe47e873090c0caca79a3f0be95259faad84

Contents?: true

Size: 915 Bytes

Versions: 18

Compression:

Stored size: 915 Bytes

Contents

class Baza::Driver::Mysql::Commands
  def initialize(args)
    @db = args.fetch(:db)
  end

  def upsert_duplicate_key(table_name, updates, terms, args = {})
    Baza::SqlQueries::MysqlUpsertDuplicateKey.new(
      db: @db,
      table_name: table_name,
      updates: updates,
      terms: terms,
      buffer: args[:buffer],
      return_id: args[:return_id]
    ).execute
  end

  def upsert(table_name, updates, terms, args = {})
    if args[:buffer]
      Baza::SqlQueries::NonAtomicUpsert.new(
        db: @db,
        table_name: table_name,
        buffer: args[:buffer],
        terms: terms,
        updates: updates
      ).execute
    else
      Baza::SqlQueries::MysqlUpsert.new(
        db: @db,
        table_name: table_name,
        updates: updates,
        terms: terms
      ).execute
    end
  end

  def last_id
    @db.query("SELECT LAST_INSERT_ID() AS `id`").fetch.fetch(:id).to_i
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
baza-0.0.38 lib/baza/driver/mysql/commands.rb
baza-0.0.37 lib/baza/driver/mysql/commands.rb
baza-0.0.36 lib/baza/driver/mysql/commands.rb
baza-0.0.35 lib/baza/driver/mysql/commands.rb
baza-0.0.34 lib/baza/driver/mysql/commands.rb
baza-0.0.33 lib/baza/driver/mysql/commands.rb
baza-0.0.32 lib/baza/driver/mysql/commands.rb
baza-0.0.31 lib/baza/driver/mysql/commands.rb
baza-0.0.30 lib/baza/driver/mysql/commands.rb
baza-0.0.29 lib/baza/driver/mysql/commands.rb
baza-0.0.28 lib/baza/driver/mysql/commands.rb
baza-0.0.27 lib/baza/driver/mysql/commands.rb
baza-0.0.26 lib/baza/driver/mysql/commands.rb
baza-0.0.25 lib/baza/driver/mysql/commands.rb
baza-0.0.24 lib/baza/driver/mysql/commands.rb
baza-0.0.23 lib/baza/driver/mysql/commands.rb
baza-0.0.22 lib/baza/driver/mysql/commands.rb
baza-0.0.21 lib/baza/driver/mysql/commands.rb