Class: ActiveRecord::ConnectionAdapters::DSQLAdapter

Inherits:
PostgreSQLAdapter
  • Object
show all
Defined in:
lib/active_record/connection_adapters/dsql_adapter.rb

Constant Summary collapse

ADAPTER_NAME =
"DSQL"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dbconsole(config, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 23

def dbconsole(config, options = {})
  config_hash = config.configuration_hash.dup

  config_hash[:sslmode] ||= "require"
  config_hash[:database] ||= "postgres"
  config_hash[:username] ||= "admin"
  config_hash[:password] ||= generate_password(config_hash)

  config = ActiveRecord::DatabaseConfigurations::HashConfig.new(config.env_name, config.name, config_hash)

  super(config, options)
end

.native_database_typesObject

DSQL doesn’t support serial or bigserial, nor sequences, but seems to endorse using uuid with default random function uuids for primary keys

docs.aws.amazon.com/aurora-dsql/latest/userguide/getting-started.html



55
56
57
58
59
60
61
62
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 55

def self.native_database_types # :nodoc:
  @native_database_types ||= begin
    types = NATIVE_DATABASE_TYPES.dup
    types[:primary_key] = "uuid primary key unique default gen_random_uuid()"
    types[:datetime] = types[datetime_type]
    types
  end
end

.new_client(conn_params) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 14

def new_client(conn_params)
  conn_params[:sslmode] ||= "require"
  conn_params[:dbname] ||= "postgres"
  conn_params[:user] ||= "admin"
  conn_params[:password] ||= generate_password(conn_params)

  super(conn_params)
end

Instance Method Details

#client_min_messagesObject

DSQL doesn’t support these parameters, but PostgreSQLAdapter always sets them in #configure_connection



66
67
68
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 66

def client_min_messages
  nil
end

#client_min_messages=(value) ⇒ Object



70
71
72
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 70

def client_min_messages=(value)
  nil
end

#create_schema_dumper(options) ⇒ Object

:nodoc:



153
154
155
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 153

def create_schema_dumper(options) # :nodoc:
  DSQL::SchemaDumper.create(self, options)
end

#primary_keys(table_name) ⇒ Object

DSQL creates a primary key index which INCLUDES all columns in the table. We use indnkeyatts to only take notice of key (not INCLUDE-ed) columns for the primary key.

www.postgresql.org/docs/current/catalog-pg-index.html



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 136

def primary_keys(table_name) # :nodoc:
  query_values(<<~SQL, "SCHEMA")
    SELECT a.attname
      FROM (
             SELECT indrelid, indnkeyatts, indkey, generate_subscripts(indkey, 1) idx
               FROM pg_index
              WHERE indrelid = #{quote(quote_table_name(table_name))}::regclass
                AND indisprimary
           ) i
      JOIN pg_attribute a
        ON a.attrelid = i.indrelid
       AND a.attnum = i.indkey[i.idx]
     WHERE i.idx < i.indnkeyatts
     ORDER BY i.idx
  SQL
end

#schema_namesObject



126
127
128
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 126

def schema_names
  super - ["sys"]
end

#set_standard_conforming_stringsObject



74
75
76
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 74

def set_standard_conforming_strings
  nil
end

#supports_advisory_locks?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 80

def supports_advisory_locks?
  false
end

#supports_ddl_transactions?Boolean

DSQL does support DDL transactions, but does not support mixing DDL and DML, so inserting the migration version into the schema_migrations table fails unless we turn off the DDL transaction.

PG::FeatureNotSupported: ERROR: ddl and dml are not supported in the same transaction

Returns:

  • (Boolean)


118
119
120
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 118

def supports_ddl_transactions?
  false
end

#supports_exclusion_constraints?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 96

def supports_exclusion_constraints?
  false
end

#supports_extensions?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 100

def supports_extensions?
  false
end

#supports_foreign_keys?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 92

def supports_foreign_keys?
  false
end

#supports_index_sort_order?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 104

def supports_index_sort_order?
  false
end

#supports_json?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 108

def supports_json?
  false
end

#supports_materialized_views?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 88

def supports_materialized_views?
  false
end

#supports_views?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 84

def supports_views?
  false
end