Namespace

Class/Module Index [+]

Quicksearch

JdbcSpec::MySQL

Public Class Methods

adapter_matcher(name, *) click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 28
def self.adapter_matcher(name, *)
  name =~ /mysql/ ? self : false
end
column_selector() click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 32
def self.column_selector
  [/mysql/, lambda {|cfg,col| col.extend(::JdbcSpec::MySQL::Column)}]
end
extended(adapter) click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 36
def self.extended(adapter)
  adapter.execute("SET SQL_AUTO_IS_NULL=0")
end

Public Instance Methods

charset() click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 223
def charset
  show_variable("character_set_database")
end
collation() click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 227
def collation
  show_variable("collation_database")
end
current_database() click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 169
def current_database
  select_one("SELECT DATABASE() as db")["db"]
end
modify_types(tp) click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 66
def modify_types(tp)
  tp[:primary_key] = "int(11) DEFAULT NULL auto_increment PRIMARY KEY"
  tp[:decimal] = { :name => "decimal" }
  tp[:timestamp] = { :name => "datetime" }
  tp[:datetime][:limit] = nil
  tp
end
quote(value, column = nil) click to toggle source

QUOTING ==================================================

# File lib/jdbc_adapter/jdbc_mysql.rb, line 76
def quote(value, column = nil)
  return value.quoted_id if value.respond_to?(:quoted_id)

  if column && column.type == :primary_key
    value.to_s
  elsif column && String === value && column.type == :binary && column.class.respond_to?(:string_to_binary)
    s = column.class.string_to_binary(value).unpack("H*")[0]
    "x'#{s}'"
  elsif BigDecimal === value
    "'#{value.to_s("F")}'"
  else
    super
  end
end
quoted_false() click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 95
def quoted_false
    "0"
end
quoted_true() click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 91
def quoted_true
    "1"
end
rename_table(name, new_name) click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 177
def rename_table(name, new_name)
  execute "RENAME TABLE #{quote_table_name(name)} TO #{quote_table_name(new_name)}"
end
show_variable(var) click to toggle source
# File lib/jdbc_adapter/jdbc_mysql.rb, line 217
def show_variable(var)
  res = execute("show variables like '#{var}'")
  row = res.detect {|row| row["Variable_name"] == var }
  row && row["Value"]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.