Methods
- A
- C
- D
- N
- P
- S
- T
Included Modules
Constants
ADAPTER_NAME | = | "Trilogy" |
ER_ACCESS_DENIED_ERROR | = | 1045 |
ER_BAD_DB_ERROR | = | 1049 |
ER_DBACCESS_DENIED_ERROR | = | 1044 |
SSL_MODES | = | { SSL_MODE_DISABLED: ::Trilogy::SSL_DISABLED, SSL_MODE_PREFERRED: ::Trilogy::SSL_PREFERRED_NOVERIFY, SSL_MODE_REQUIRED: ::Trilogy::SSL_REQUIRED_NOVERIFY, SSL_MODE_VERIFY_CA: ::Trilogy::SSL_VERIFY_CA, SSL_MODE_VERIFY_IDENTITY: ::Trilogy::SSL_VERIFY_IDENTITY }.freeze |
TYPE_MAP | = | Type::TypeMap.new.tap { |m| initialize_type_map(m) } |
Class Public methods
new(config, *) Link
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 75 def initialize(config, *) config = config.dup # Trilogy ignores `socket` if `host is set. We want the opposite to allow # configuring UNIX domain sockets via `DATABASE_URL`. config.delete(:host) if config[:socket] # Set FOUND_ROWS capability on the connection so UPDATE queries returns number of rows # matched rather than number of rows updated. config[:found_rows] = true if config[:prepared_statements] raise ArgumentError, "Trilogy currently doesn't support prepared statements. Remove `prepared_statements: true` from your database configuration." end super end
new_client(config) Link
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 30 def new_client(config) config[:ssl_mode] = parse_ssl_mode(config[:ssl_mode]) if config[:ssl_mode] ::Trilogy.new(config) rescue ::Trilogy::Error => error raise translate_connect_error(config, error) end
parse_ssl_mode(mode) Link
translate_connect_error(config, error) Link
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 46 def translate_connect_error(config, error) case error.error_code when ER_DBACCESS_DENIED_ERROR, ER_BAD_DB_ERROR ActiveRecord::NoDatabaseError.db_error(config[:database]) when ER_ACCESS_DENIED_ERROR ActiveRecord::DatabaseConnectionError.username_error(config[:username]) else if error.message.include?("TRILOGY_DNS_ERROR") ActiveRecord::DatabaseConnectionError.hostname_error(config[:host]) else ActiveRecord::ConnectionNotEstablished.new(error.message) end end end