Class: ActiveRecord::ConnectionAdapters::DSQLAdapter
- Inherits:
-
PostgreSQLAdapter
- Object
- PostgreSQLAdapter
- ActiveRecord::ConnectionAdapters::DSQLAdapter
- Defined in:
- lib/active_record/connection_adapters/dsql_adapter.rb
Constant Summary collapse
- ADAPTER_NAME =
"DSQL"
Class Method Summary collapse
- .dbconsole(config, options = {}) ⇒ Object
-
.native_database_types ⇒ Object
DSQL doesn’t support serial or bigserial, nor sequences, but seems to endorse using uuid with default random function uuids for primary keys.
- .new_client(conn_params) ⇒ Object
Instance Method Summary collapse
-
#client_min_messages ⇒ Object
DSQL doesn’t support these parameters, but PostgreSQLAdapter always sets them in #configure_connection.
- #client_min_messages=(value) ⇒ Object
-
#create_schema_dumper(options) ⇒ Object
:nodoc:.
-
#primary_keys(table_name) ⇒ Object
DSQL creates a primary key index which INCLUDES all columns in the table.
-
#schema_names ⇒ Object
Ignore DSQL sys schema.
- #set_standard_conforming_strings ⇒ Object
- #supports_advisory_locks? ⇒ Boolean
-
#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.
- #supports_exclusion_constraints? ⇒ Boolean
- #supports_extensions? ⇒ Boolean
- #supports_foreign_keys? ⇒ Boolean
- #supports_index_sort_order? ⇒ Boolean
- #supports_json? ⇒ Boolean
- #supports_materialized_views? ⇒ Boolean
- #supports_views? ⇒ Boolean
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, = {}) 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, ) end |
.native_database_types ⇒ Object
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_messages ⇒ Object
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 nil end |
#client_min_messages=(value) ⇒ Object
70 71 72 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 70 def (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() # :nodoc: DSQL::SchemaDumper.create(self, ) 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.
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_names ⇒ Object
Ignore DSQL sys schema.
docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-systems-tables.html
126 127 128 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 126 def schema_names super - ["sys"] end |
#set_standard_conforming_strings ⇒ Object
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
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
118 119 120 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 118 def supports_ddl_transactions? false end |
#supports_exclusion_constraints? ⇒ Boolean
96 97 98 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 96 def supports_exclusion_constraints? false end |
#supports_extensions? ⇒ Boolean
100 101 102 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 100 def supports_extensions? false end |
#supports_foreign_keys? ⇒ 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
104 105 106 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 104 def supports_index_sort_order? false end |
#supports_json? ⇒ Boolean
108 109 110 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 108 def supports_json? false end |
#supports_materialized_views? ⇒ Boolean
88 89 90 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 88 def supports_materialized_views? false end |
#supports_views? ⇒ Boolean
84 85 86 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 84 def supports_views? false end |