Module: Torque::PostgreSQL::Adapter

Includes:
DatabaseStatements, Quoting, SchemaStatements
Defined in:
lib/torque/postgresql/adapter.rb,
lib/torque/postgresql/adapter/oid.rb,
lib/torque/postgresql/adapter/oid/box.rb,
lib/torque/postgresql/adapter/quoting.rb,
lib/torque/postgresql/adapter/oid/enum.rb,
lib/torque/postgresql/adapter/oid/line.rb,
lib/torque/postgresql/adapter/oid/range.rb,
lib/torque/postgresql/adapter/oid/circle.rb,
lib/torque/postgresql/adapter/oid/segment.rb,
lib/torque/postgresql/adapter/oid/enum_set.rb,
lib/torque/postgresql/adapter/oid/interval.rb,
lib/torque/postgresql/adapter/schema_dumper.rb,
lib/torque/postgresql/adapter/schema_creation.rb,
lib/torque/postgresql/adapter/schema_statements.rb,
lib/torque/postgresql/adapter/schema_definitions.rb,
lib/torque/postgresql/adapter/database_statements.rb

Defined Under Namespace

Modules: DatabaseStatements, OID, Quoting, SchemaCreation, SchemaDumper, SchemaStatements, TableDefinition Classes: DeduplicatableArray

Constant Summary

Constants included from SchemaStatements

SchemaStatements::TableDefinition

Constants included from DatabaseStatements

DatabaseStatements::EXTENDED_DATABASE_TYPES

Constants included from Quoting

Quoting::Column, Quoting::ColumnDefinition, Quoting::Name

Instance Method Summary collapse

Methods included from SchemaStatements

#add_enum_values, #change_table, #create_schema, #create_table, #data_source_sql, #drop_schema, #drop_table, #drop_type, #enum_values, #quoted_scope, #rename_type, #table_options, #valid_table_definition_options

Methods included from DatabaseStatements

#column_definitions, #configure_connection, #create_enum, #dump_mode!, #extended_types, #inherited_tables, #initialize_type_map, #load_additional_types, #schema_exists?, #schemas_blacklist, #schemas_search_path_sanitized, #schemas_whitelist, #torque_load_additional_types, #type_exists?, #user_defined_schemas, #user_defined_schemas_sql, #user_defined_types, #valid_type?

Methods included from Quoting

#quote_default_expression, #quote_type_name

Instance Method Details

#build_insert_sql(insert) ⇒ Object

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



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/torque/postgresql/adapter.rb', line 41

def build_insert_sql(insert)
  super.tap do |sql|
    if insert.update_duplicates? && insert.where_condition?
      if insert.returning
        sql.sub!(' RETURNING ', " WHERE #{insert.where} RETURNING ")
      else
        sql << " WHERE #{insert.where}"
      end
    end
  end
end

#extract_table_options!(options) ⇒ Object

Add ‘inherits` and `schema` to the list of extracted table options



35
36
37
# File 'lib/torque/postgresql/adapter.rb', line 35

def extract_table_options!(options)
  super.merge(options.extract!(:inherits, :schema))
end

#versionObject

Get the current PostgreSQL version as a Gem Version.



28
29
30
31
32
# File 'lib/torque/postgresql/adapter.rb', line 28

def version
  @version ||= Gem::Version.new(
    select_value('SELECT version()').match(/#{Adapter::ADAPTER_NAME} ([\d\.]+)/)[1]
  )
end