Module: Spectacles::SchemaStatements::SQLite3Adapter
- Includes:
- AbstractAdapter
- Defined in:
- lib/spectacles/schema_statements/sqlite3_adapter.rb
Instance Method Summary collapse
- #generate_view_query(*columns) ⇒ Object
- #view_build_query(table_name) ⇒ Object
-
#views ⇒ Object
:nodoc:.
Methods included from AbstractAdapter
#create_materialized_view, #create_view, #create_view_statement, #drop_materialized_view, #drop_view, #drop_view_statement, #materialized_view_build_query, #materialized_view_exists?, #materialized_views, #refresh_materialized_view, #refresh_materialized_view_concurrently, #supports_materialized_views?, #view_exists?
Instance Method Details
#generate_view_query(*columns) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/spectacles/schema_statements/sqlite3_adapter.rb', line 8 def generate_view_query(*columns) <<-SQL SELECT #{columns.join(",")} FROM sqlite_master WHERE type = 'view' SQL end |
#view_build_query(table_name) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/spectacles/schema_statements/sqlite3_adapter.rb', line 24 def view_build_query(table_name) sql = generate_view_query(:sql) sql << " AND name = #{quote_table_name(table_name)}" row = exec_query(sql, "SCHEMA").first row["sql"].gsub(/CREATE VIEW .*? AS/i, "") end |
#views ⇒ Object
:nodoc:
16 17 18 19 20 21 22 |
# File 'lib/spectacles/schema_statements/sqlite3_adapter.rb', line 16 def views # :nodoc: sql = generate_view_query(:name) exec_query(sql, "SCHEMA").map do |row| row["name"] end end |