Module: RailsSqlViews::ConnectionAdapters::SQLiteAdapter
- Defined in:
- lib/rails_sql_views/connection_adapters/sqlite_adapter.rb
Instance Method Summary collapse
- #base_tables(name = nil) ⇒ Object (also: #nonview_tables)
- #supports_drop_table_cascade? ⇒ Boolean
- #supports_view_columns_definition? ⇒ Boolean
- #supports_views? ⇒ Boolean
-
#tables(name = nil) ⇒ Object
:nodoc:.
-
#view_select_statement(view, name = nil) ⇒ Object
Get the view select statement for the specified table.
- #views(name = nil) ⇒ Object
Instance Method Details
#base_tables(name = nil) ⇒ Object Also known as: nonview_tables
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 24 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_drop_table_cascade? ⇒ Boolean
8 9 10 |
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 8 def supports_drop_table_cascade? return false end |
#supports_view_columns_definition? ⇒ Boolean
60 61 62 |
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 60 def supports_view_columns_definition? false end |
#supports_views? ⇒ 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:
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 12 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.
50 51 52 53 54 55 56 57 58 |
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 50 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).gsub("CREATE VIEW #{view} AS ", "")) or raise "No view called #{view} found" end |
#views(name = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rails_sql_views/connection_adapters/sqlite_adapter.rb', line 37 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 |