Active Record MySQL2 适配器
方法
- A
- C
- D
- E
- N
- S
包含的模块
常量
ADAPTER_NAME | = | "Mysql2" |
ER_ACCESS_DENIED_ERROR | = | 1045 |
ER_BAD_DB_ERROR | = | 1049 |
ER_CONN_HOST_ERROR | = | 2003 |
ER_DBACCESS_DENIED_ERROR | = | 1044 |
ER_UNKNOWN_HOST_ERROR | = | 2005 |
TYPE_MAP | = | Type::TypeMap.new.tap { |m| initialize_type_map(m) } |
类公共方法
new(...) 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 55 def initialize(...) super @affected_rows_before_warnings = nil @config[:flags] ||= 0 if @config[:flags].kind_of? Array @config[:flags].push "FOUND_ROWS" else @config[:flags] |= ::Mysql2::Client::FOUND_ROWS end @connection_parameters ||= @config end
new_client(config) 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 24 def new_client(config) ::Mysql2::Client.new(config) rescue ::Mysql2::Error => error case error.error_number when ER_BAD_DB_ERROR raise ActiveRecord::NoDatabaseError.db_error(config[:database]) when ER_DBACCESS_DENIED_ERROR, ER_ACCESS_DENIED_ERROR raise ActiveRecord::DatabaseConnectionError.username_error(config[:username]) when ER_CONN_HOST_ERROR, ER_UNKNOWN_HOST_ERROR raise ActiveRecord::DatabaseConnectionError.hostname_error(config[:host]) else raise ActiveRecord::ConnectionNotEstablished, error.message end end
实例公共方法
active?() 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 108 def active? connected? && @lock.synchronize { @raw_connection&.ping } || false end
connected?() 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 104 def connected? !(@raw_connection.nil? || @raw_connection.closed?) end
disconnect!() 链接
如果已连接,则断开与数据库的连接。 否则,此方法不执行任何操作。
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 116 def disconnect! @lock.synchronize do super @raw_connection&.close @raw_connection = nil end end
error_number(exception) 链接
辅助方法 ===========================================
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 96 def error_number(exception) exception.error_number if exception.respond_to?(:error_number) end
savepoint_errors_invalidate_transactions?() 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 86 def savepoint_errors_invalidate_transactions? true end
supports_comments?() 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 74 def supports_comments? true end
supports_comments_in_create?() 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 78 def supports_comments_in_create? true end
supports_json?() 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 70 def supports_json? !mariadb? && database_version >= "5.7.8" end
supports_lazy_transactions?() 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 90 def supports_lazy_transactions? true end
supports_savepoints?() 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 82 def supports_savepoints? true end