Class: ActiveRecord::ConnectionAdapters::AwsDataServiceMysql::Connection
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::AwsDataServiceMysql::Connection
- Defined in:
- lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb
Instance Attribute Summary collapse
-
#query_options ⇒ Object
readonly
Returns the value of attribute query_options.
Instance Method Summary collapse
- #abandon_results! ⇒ Object
- #affected_rows ⇒ Object
- #begin_db_transaction ⇒ Object
- #close ⇒ Object
- #commit_db_transaction ⇒ Object
- #exec_rollback_db_transaction ⇒ Object
-
#initialize(secret_arn:, resource_arn:, database:, **config) ⇒ Connection
constructor
A new instance of Connection.
- #last_id ⇒ Object
- #ping ⇒ Object
- #query(sql, **query_options) ⇒ Object
- #server_info ⇒ Object
Constructor Details
#initialize(secret_arn:, resource_arn:, database:, **config) ⇒ Connection
Returns a new instance of Connection.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 45 def initialize(secret_arn:, resource_arn:, database:, **config) @client = ::Aws::RDSDataService::Client.new @secret_arn = secret_arn @resource_arn = resource_arn @database = database @query_options = { database_timezone: :local, as: :array, # Mysql2 default is hash symbolize_keys: false } end |
Instance Attribute Details
#query_options ⇒ Object (readonly)
Returns the value of attribute query_options.
43 44 45 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 43 def @query_options end |
Instance Method Details
#abandon_results! ⇒ Object
69 70 71 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 69 def abandon_results! # nop end |
#affected_rows ⇒ Object
73 74 75 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 73 def affected_rows @last_result.number_of_records_updated end |
#begin_db_transaction ⇒ Object
87 88 89 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 87 def begin_db_transaction @current_transaction = client.begin_transaction(secret_arn: secret_arn, resource_arn: resource_arn, database: database) end |
#close ⇒ Object
65 66 67 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 65 def close # nop end |
#commit_db_transaction ⇒ Object
91 92 93 94 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 91 def commit_db_transaction client.commit_transaction(secret_arn: secret_arn, resource_arn: resource_arn, transaction_id: @current_transaction.transaction_id) @current_transaction = nil end |
#exec_rollback_db_transaction ⇒ Object
96 97 98 99 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 96 def exec_rollback_db_transaction client.rollback_transaction(secret_arn: secret_arn, resource_arn: resource_arn, transaction_id: @current_transaction.transaction_id) @current_transaction = nil end |
#last_id ⇒ Object
77 78 79 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 77 def last_id @last_result.generated_fields.first.values.compact.first end |
#ping ⇒ Object
61 62 63 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 61 def ping query('SELECT 1') end |
#query(sql, **query_options) ⇒ Object
57 58 59 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 57 def query(sql, **) _query(sql, **@query_options.merge()) end |
#server_info ⇒ Object
81 82 83 84 85 |
# File 'lib/active_record/connection_adapters/aws_data_service_mysql/connection.rb', line 81 def server_info { version: query('SHOW VARIABLES LIKE "version";', as: :array).first.last } end |