module Torque::PostgreSQL::Adapter

Constants

INJECT_WHERE_REGEX

Public Instance Methods

build_insert_sql(insert) click to toggle source

Allow filtered bulk insert by adding the where clause. This method is only used by InsertAll, so it somewhat safe to override it

Calls superclass method
# File lib/torque/postgresql/adapter.rb, line 34
def build_insert_sql(insert)
  super.tap do |sql|
    if insert.update_duplicates? && insert.where_condition?
      if insert.returning
        sql.gsub!(INJECT_WHERE_REGEX, "\\1 WHERE #{insert.where} RETURNING")
      else
        sql << " WHERE #{insert.where}"
      end
    end
  end
end
extract_table_options!(options) click to toggle source

Add `inherits` to the list of extracted table options

Calls superclass method
# File lib/torque/postgresql/adapter.rb, line 28
def extract_table_options!(options)
  super.merge(options.extract!(:inherits))
end
version() click to toggle source

Get the current PostgreSQL version as a Gem Version.

# File lib/torque/postgresql/adapter.rb, line 21
def version
  @version ||= Gem::Version.new(
    select_value('SELECT version()').match(/#{Adapter::ADAPTER_NAME} ([\d\.]+)/)[1]
  )
end