Module: RailsSqlViews::ConnectionAdapters::PostgreSQLAdapter
- Defined in:
- lib/rails_sql_views/connection_adapters/postgresql_adapter.rb
Instance Method Summary collapse
- #base_tables(name = nil) ⇒ Object (also: #nonview_tables)
-
#supports_views? ⇒ Boolean
Returns true as this adapter supports views.
- #tables_with_views_included(name = nil) ⇒ Object
- #view_select_statement(view, name = nil) ⇒ Object
-
#views(name = nil) ⇒ Object
:nodoc:.
Instance Method Details
#base_tables(name = nil) ⇒ Object Also known as: nonview_tables
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_sql_views/connection_adapters/postgresql_adapter.rb', line 20 def base_tables(name = nil) q = " SELECT table_name, table_type\n FROM information_schema.tables\n WHERE table_schema IN (\#{schemas})\n AND table_type = 'BASE TABLE'\n SQL\n\n query(q, name).map { |row| row[0] }\nend\n" |
#supports_views? ⇒ Boolean
Returns true as this adapter supports views.
5 6 7 |
# File 'lib/rails_sql_views/connection_adapters/postgresql_adapter.rb', line 5 def supports_views? true end |
#tables_with_views_included(name = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rails_sql_views/connection_adapters/postgresql_adapter.rb', line 9 def tables_with_views_included(name = nil) q = " SELECT table_name, table_type\n FROM information_schema.tables\n WHERE table_schema IN (\#{schemas})\n AND table_type IN ('BASE TABLE', 'VIEW')\n SQL\n\n query(q, name).map { |row| row[0] }\nend\n" |
#view_select_statement(view, name = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rails_sql_views/connection_adapters/postgresql_adapter.rb', line 43 def view_select_statement(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:
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rails_sql_views/connection_adapters/postgresql_adapter.rb', line 32 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 query(q, name).map { |row| row[0] }\nend\n" |