Class: DataMapper::Adapters::Sqlite3Adapter

Constructor Summary

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

Public Visibility

Public Class Method Summary

type_map

TypeMap for SQLite 3 databases.

Returns:

Public Instance Method Summary

#field_exists?(storage_name, column_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 SQLite 3 databases.

Meta Tags

Returns:

<DataMapper::TypeMap> default TypeMap for SQLite 3 databases.

[View source]


12
13
14
15
16
17
18
19
20
# File 'dm-core/lib/dm-core/adapters/sqlite3_adapter.rb', line 12

def self.type_map



  @type_map ||= TypeMap.new(super) do |tm|
    tm.map(Integer).to('INTEGER')
    tm.map(Class).to('VARCHAR')
  end
end

Public Instance Method Details

field_exists?

public field_exists?(storage_name, column_name)

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

[View source]


28
29
30
31
32
# File 'dm-core/lib/dm-core/adapters/sqlite3_adapter.rb', line 28

def field_exists?(storage_name, column_name)
  query_table(storage_name).any? do |row|
    row.name == column_name
  end
end

storage_exists?

public storage_exists?(storage_name)

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

[View source]


20
21
22
# File 'dm-core/lib/dm-core/adapters/sqlite3_adapter.rb', line 20

def storage_exists?(storage_name)
  query_table(storage_name).size > 0
end

Protected Visibility

Protected Instance Method Summary

#normalize_uri(uri_or_options)

Protected Instance Method Details

normalize_uri

protected normalize_uri(uri_or_options)
[View source]


36
37
38
39
40
# File 'dm-core/lib/dm-core/adapters/sqlite3_adapter.rb', line 36

def normalize_uri(uri_or_options)
  uri = super
  uri.path = File.join(Dir.pwd, File.dirname(uri.path), File.basename(uri.path)) unless File.exists?(uri.path) or uri.path == ':memory:'
  uri
end