Module: Spectacles::SchemaStatements::PostgreSQLAdapter
- Includes:
- AbstractAdapter
- Defined in:
- lib/spectacles/schema_statements/postgresql_adapter.rb
Instance Method Summary collapse
Methods included from AbstractAdapter
#create_view, #create_view_statement, #drop_view, #drop_view_statement, #view_exists?
Instance Method Details
#view_build_query(view, name = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/spectacles/schema_statements/postgresql_adapter.rb', line 19 def view_build_query(view, name = nil) q = " SELECT view_definition\n FROM information_schema.views \n WHERE table_catalog = (SELECT catalog_name FROM information_schema.information_schema_catalog_name)\n AND table_schema IN (\#{schemas})\n AND table_name = '\#{view}'\n SQL\n \n select_value(q, name) or raise \"No view called \#{view} found\"\nend\n" |
#views(name = nil) ⇒ Object
:nodoc:
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/spectacles/schema_statements/postgresql_adapter.rb', line 8 def views(name = nil) #:nodoc: q = " SELECT table_name, table_type\n FROM information_schema.tables\n WHERE table_schema IN (\#{schemas})\n AND table_type = 'VIEW'\n SQL\n \n execute(q, name).map { |row| row['table_name'] }\nend\n" |