Class: Arc::DataStores::PostgresDataStore

Inherits:
AbstractDataStore show all
Defined in:
lib/arc/data_stores/postgres/store.rb

Constant Summary

Constants included from Casting

Casting::CAST_METHODS, Casting::TYPES

Instance Method Summary collapse

Methods inherited from AbstractDataStore

#[], #create, #destroy, #read, #result_for, #type_mappings_for, #update

Methods included from Casting

#cast

Methods included from Quoting

#quote, #quote_column, #quote_table

Methods included from ArelCompatibility

#columns_hash, #connection, #connection_pool, #primary_key, #quote_hash, #spec, #table_exists?, #visitor, #with_connection

Instance Method Details

#cast_binary(data) ⇒ Object



22
23
24
25
26
# File 'lib/arc/data_stores/postgres/store.rb', line 22

def cast_binary data
  with_store do |store|
    store.unescape_bytea data
  end
end

#execute(query) ⇒ Object



8
9
10
# File 'lib/arc/data_stores/postgres/store.rb', line 8

def execute query
  with_store { |connection| connection.exec query }.to_a.symbolize_keys!
end

#last_insert_rowid(table, field) ⇒ Object



28
29
30
# File 'lib/arc/data_stores/postgres/store.rb', line 28

def last_insert_rowid table, field
  id = execute("SELECT currval('#{table}_#{field}_seq');")[0][:currval]
end

#quote_binary(data) ⇒ Object



16
17
18
19
20
# File 'lib/arc/data_stores/postgres/store.rb', line 16

def quote_binary data
  with_store do |store|
    "'#{store.escape_bytea data}'"
  end
end

#schemaObject



12
13
14
# File 'lib/arc/data_stores/postgres/store.rb', line 12

def schema
  @schema ||= ObjectDefinitions::PostgresSchema.new self
end