Module: RailsSqlViews::ConnectionAdapters::SQLiteAdapter

Defined in:
lib/rails_sql_views/connection_adapters/sqlite_adapter.rb

Instance Method Summary collapse

Instance Method Details

#base_tables(name = nil) ⇒ Object Also known as: nonview_tables



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 20

def base_tables(name = nil)
  sql = <<-SQL
    SELECT name
    FROM sqlite_master
    WHERE (type = 'table') AND NOT name = 'sqlite_sequence'
  SQL

  execute(sql, name).map do |row|
    row[0]
  end        
end

#supports_view_columns_definition?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 56

def supports_view_columns_definition?
  false
end

#supports_views?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 4

def supports_views?
  true
end

#tables(name = nil) ⇒ Object

:nodoc:



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 8

def tables(name = nil) #:nodoc:
  sql = <<-SQL
    SELECT name
    FROM sqlite_master
    WHERE (type = 'table' OR type = 'view') AND NOT name = 'sqlite_sequence'
  SQL

  execute(sql, name).map do |row|
    row[0]
  end
end

#view_select_statement(view, name = nil) ⇒ Object

Get the view select statement for the specified table.



46
47
48
49
50
51
52
53
54
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 46

def view_select_statement(view, name = nil)
  sql = <<-SQL
    SELECT sql
    FROM sqlite_master
    WHERE name = '#{view}' AND NOT name = 'sqlite_sequence'
  SQL
  
  select_value(sql, name) or raise "No view called #{view} found"
end

#views(name = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 33

def views(name = nil)
  sql = <<-SQL
    SELECT name
    FROM sqlite_master
    WHERE type = 'view' AND NOT name = 'sqlite_sequence'
  SQL

  execute(sql, name).map do |row|
    row[0]
  end
end