class Baza::Driver::Pg::Commands
Public Class Methods
new(args)
click to toggle source
# File lib/baza/driver/pg/commands.rb, line 2 def initialize(args) @db = args.fetch(:db) end
Public Instance Methods
last_id()
click to toggle source
# File lib/baza/driver/pg/commands.rb, line 28 def last_id @db.query("SELECT LASTVAL() AS id").fetch.fetch(:id).to_i end
upsert(table_name, updates, terms, args = {})
click to toggle source
# File lib/baza/driver/pg/commands.rb, line 17 def upsert(table_name, updates, terms, args = {}) @last_insert_table_name = table_name.to_s Baza::SqlQueries::NonAtomicUpsert.new({ db: @db, table_name: table_name, terms: terms, updates: updates }.merge(args)).execute end
upsert_duplicate_key(table_name, updates, terms, args = {})
click to toggle source
# File lib/baza/driver/pg/commands.rb, line 6 def upsert_duplicate_key(table_name, updates, terms, args = {}) @last_insert_table_name = table_name.to_s Baza::SqlQueries::PostgresUpsertDuplicateKey.new({ db: @db, table_name: table_name, updates: updates, terms: terms }.merge(args)).execute end
version()
click to toggle source
# File lib/baza/driver/pg/commands.rb, line 32 def version @version ||= @db.query("SELECT VERSION() AS version").fetch.fetch(:version).match(/\APostgreSQL ([\d\.]+)/)[1] end