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:.
- #index_algorithms ⇒ Object
-
#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
Methods included from ActiveRecord::ConnectionAdapters::DSQL::SchemaStatements
Class Method Details
.dbconsole(config, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 25 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
57 58 59 60 61 62 63 64 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 57 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
16 17 18 19 20 21 22 23 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 16 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
68 69 70 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 68 def nil end |
#client_min_messages=(value) ⇒ Object
72 73 74 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 72 def (value) nil end |
#create_schema_dumper(options) ⇒ Object
:nodoc:
159 160 161 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 159 def create_schema_dumper() # :nodoc: DSQL::SchemaDumper.create(self, ) end |
#index_algorithms ⇒ Object
124 125 126 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 124 def index_algorithms { async: "ASYNC" } 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.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 142 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
132 133 134 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 132 def schema_names super - ["sys"] end |
#set_standard_conforming_strings ⇒ Object
76 77 78 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 76 def set_standard_conforming_strings nil end |
#supports_advisory_locks? ⇒ Boolean
82 83 84 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 82 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
120 121 122 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 120 def supports_ddl_transactions? false end |
#supports_exclusion_constraints? ⇒ Boolean
98 99 100 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 98 def supports_exclusion_constraints? false end |
#supports_extensions? ⇒ Boolean
102 103 104 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 102 def supports_extensions? false end |
#supports_foreign_keys? ⇒ Boolean
94 95 96 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 94 def supports_foreign_keys? false end |
#supports_index_sort_order? ⇒ Boolean
106 107 108 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 106 def supports_index_sort_order? false end |
#supports_json? ⇒ Boolean
110 111 112 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 110 def supports_json? false end |
#supports_materialized_views? ⇒ Boolean
90 91 92 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 90 def supports_materialized_views? false end |
#supports_views? ⇒ Boolean
86 87 88 |
# File 'lib/active_record/connection_adapters/dsql_adapter.rb', line 86 def supports_views? false end |