module Sequel::MySQL::MysqlMysql2::DatabaseMethods
Constants
- MYSQL_DATABASE_DISCONNECT_ERRORS
Public Instance Methods
Source
# File lib/sequel/adapters/utils/mysql_mysql2.rb 27 def call_sproc(name, opts=OPTS, &block) 28 args = opts[:args] || [] 29 execute("CALL #{name}#{args.empty? ? '()' : literal(args)}", opts.merge(:sproc=>false), &block) 30 end
Support stored procedures on MySQL
Source
# File lib/sequel/adapters/utils/mysql_mysql2.rb 34 def execute(sql, opts=OPTS, &block) 35 if opts[:sproc] 36 call_sproc(sql, opts, &block) 37 elsif sql.is_a?(Symbol) || sql.is_a?(Sequel::Dataset::ArgumentMapper) 38 execute_prepared_statement(sql, opts, &block) 39 else 40 synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)} 41 end 42 end
Executes the given SQL
using an available connection, yielding the connection if the block is given.
Private Instance Methods
Source
# File lib/sequel/adapters/utils/mysql_mysql2.rb 46 def add_prepared_statements_cache(conn) 47 class << conn 48 attr_accessor :prepared_statements 49 end 50 conn.prepared_statements = {} 51 end
Source
# File lib/sequel/adapters/utils/mysql_mysql2.rb 53 def database_specific_error_class(exception, opts) 54 case exception.errno 55 when 1048 56 NotNullConstraintViolation 57 when 1062 58 UniqueConstraintViolation 59 when 1451, 1452, 1216, 1217 60 ForeignKeyConstraintViolation 61 when 4025 62 CheckConstraintViolation 63 when 1205 64 DatabaseLockTimeout 65 else 66 super 67 end 68 end
Calls superclass method