Class: DataMapper::Adapters::MysqlAdapter

Options: host, user, password, database (path), socket(uri query string), port

Constructor Summary

This class inherits a constructor from DataMapper::Adapters::DataObjectsAdapter.

Public Visibility

Public Class Method Summary

type_map

TypeMap for MySql databases.

Returns:

Public Instance Method Summary

#field_exists?(storage_name, field_name)

TODO: move to dm-more/dm-migrations (if possible).

#storage_exists?(storage_name)

TODO: move to dm-more/dm-migrations (if possible).

Public Class Method Details

type_map

public type_map

TypeMap for MySql databases.

Meta Tags

Returns:

<DataMapper::TypeMap> default TypeMap for MySql databases.

[View source]


14
15
16
17
18
19
20
21
22
23
# File 'dm-core/lib/dm-core/adapters/mysql_adapter.rb', line 14

def self.type_map



  @type_map ||= TypeMap.new(super) do |tm|
    tm.map(Integer).to('INT').with(:size => 11)
    tm.map(TrueClass).to('TINYINT').with(:size => 1)  # TODO: map this to a BIT or CHAR(0) field?
    tm.map(Object).to('TEXT')
  end
end

Public Instance Method Details

field_exists?

public field_exists?(storage_name, field_name)

TODO: move to dm-more/dm-migrations (if possible)

[View source]


38
39
40
41
42
# File 'dm-core/lib/dm-core/adapters/mysql_adapter.rb', line 38

def field_exists?(storage_name, field_name)
  statement = "SELECT COUNT(*)\nFROM `information_schema`.`columns`\nWHERE `table_schema` = ? AND `table_name` = ? AND `column_name` = ?\n".compress_lines

  query(statement, db_name, storage_name, field_name).first > 0
end

storage_exists?

public storage_exists?(storage_name)

TODO: move to dm-more/dm-migrations (if possible)

[View source]


23
24
25
26
27
# File 'dm-core/lib/dm-core/adapters/mysql_adapter.rb', line 23

def storage_exists?(storage_name)
  statement = "SELECT COUNT(*)\nFROM `information_schema`.`columns`\nWHERE `table_schema` = ? AND `table_name` = ?\n".compress_lines

  query(statement, db_name, storage_name).first > 0
end

Protected Visibility