Class: DataMapper::Adapters::MysqlAdapter
- Object
- DataMapper::Adapters::AbstractAdapter
- DataMapper::Adapters::DataObjectsAdapter
- DataMapper::Adapters::MysqlAdapter
Included Modules
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 Instance Methods Inherited from DataMapper::Adapters::DataObjectsAdapter
avg, count, create, create_model_storage, delete, destroy_model_storage, execute, max, min, query, read_set, sum, transaction_primitive, update, upgrade_model_storage
Public Instance Methods Inherited from DataMapper::Adapters::AbstractAdapter
alter_model_storage, alter_property_storage, create_property_storage, current_transaction, delete_set, destroy_property_storage, pop_transaction, push_transaction, read, read_one, within_transaction?
Public Instance Methods Inherited from Object
Public Class Method Details
type_map
TypeMap for MySql databases.
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?
TODO: move to dm-more/dm-migrations (if possible)
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?
TODO: move to dm-more/dm-migrations (if possible)
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