Class: DataMapper::Adapters::SqliteAdapter

Inherits:
DataObjectsAdapter
  • Object
show all
Defined in:
lib/dm-sqlite-adapter/adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ SqliteAdapter

Returns a new instance of SqliteAdapter.



9
10
11
# File 'lib/dm-sqlite-adapter/adapter.rb', line 9

def initialize(name, options)
  super(name, normalize_options(options))
end

Instance Method Details

#normalize_options(options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dm-sqlite-adapter/adapter.rb', line 19

def normalize_options(options)
  # TODO Once do_sqlite3 accepts both a Pathname or a String,
  # normalizing database and path won't be necessary anymore
  # Clean out all the 'path-like' parameters in the options hash
  # ensuring there can only be one.
  # Also make sure a blank value can't possibly mask a non-blank one
  path = nil
  [:path, 'path', :database, 'database'].each do |key|
    db = options.delete(key)
    unless db.nil?
      normalized_db = db.to_s # no Symbol#empty? on 1.8.7(ish) rubies
      path ||= normalized_db unless normalized_db.empty?
    end
  end

  options.update(:adapter => 'sqlite3', :path => path)
end

#supports_subquery?(query, source_key, target_key, qualify) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/dm-sqlite-adapter/adapter.rb', line 14

def supports_subquery?(query, source_key, target_key, qualify)
  # SQLite3 cannot match a subquery against more than one column
  source_key.size == 1 && target_key.size == 1
end