# File lib/active_record/connection_adapters/redshift_adapter.rb, line 155 def primary_keys(table) row = exec_query(<<-end_sql, 'SCHEMA').rows.map do |row| SELECT DISTINCT(attr.attname) FROM pg_attribute attr INNER JOIN pg_depend dep ON attr.attrelid = dep.refobjid AND attr.attnum = dep.refobjsubid INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1] WHERE cons.contype = 'p' AND dep.refobjid = '#{quote_table_name(table)}'::regclass end_sql row && row.first end end
class ActiveRecord::ConnectionAdapters::RedshiftAdapter
Constants
- ADAPTER_NAME
- NATIVE_DATABASE_TYPES
Public Class Methods
new(connection, logger, connection_parameters, config)
click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 37 def initialize(connection, logger, connection_parameters, config) super end
Public Instance Methods
configure_connection()
click to toggle source
Configures the encoding, verbosity, schema search path, and time zone of the connection. This is called by connect and should not be called manually.
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 43 def configure_connection if @config[:encoding] @connection.set_client_encoding(@config[:encoding]) end # self.client_min_messages = @config[:min_messages] || 'warning' self.schema_search_path = @config[:schema_search_path] || @config[:schema_order] # Use standard-conforming strings so we don't have to do the E'...' dance. # set_standard_conforming_strings # If using Active Record's time zone support configure the connection to return # TIMESTAMP WITH ZONE types in UTC. # (SET TIME ZONE does not use an equals sign like other SET variables) # if ActiveRecord::Base.default_timezone == :utc # execute("SET time zone 'UTC'", 'SCHEMA') # elsif @local_tz # execute("SET time zone '#{@local_tz}'", 'SCHEMA') # end # SET statements from :variables config hash # http://www.postgresql.org/docs/8.3/static/sql-set.html variables = @config[:variables] || {} variables.map do |k, v| if v == ':default' || v == :default # Sets the value to the global or compile default execute("SET SESSION #{k} TO DEFAULT", 'SCHEMA') elsif !v.nil? execute("SET SESSION #{k} TO #{quote(v)}", 'SCHEMA') end end end
get_advisory_lock(lock_id)
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 172 def get_advisory_lock(lock_id) lock_id end
indexes(table_name, name = nil)
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 168 def indexes(table_name, name = nil) [] end
postgresql_version()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 75 def postgresql_version # Hack to avoid native PostgreQLAdapter's version check return 100000 + 80002 end
primary_keys(table)
click to toggle source
Returns just a table’s primary key
release_advisory_lock(lock_id)
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 176 def release_advisory_lock(lock_id) end
supports_extensions?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 108 def supports_extensions? false end
supports_foreign_keys?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 100 def supports_foreign_keys? false end
supports_index_sort_order?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 88 def supports_index_sort_order? false end
supports_materialized_views?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 116 def supports_materialized_views? false end
supports_partial_index?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 92 def supports_partial_index? false end
supports_ranges?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 112 def supports_ranges? false end
supports_statement_cache?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 84 def supports_statement_cache? false end
supports_transaction_isolation?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 96 def supports_transaction_isolation? false end
supports_views?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 104 def supports_views? false end
use_insert_returning?()
click to toggle source
# File lib/active_record/connection_adapters/redshift_adapter.rb, line 120 def use_insert_returning? false end