Class: ActiveRecord::View::Introspection::Postgres
- Defined in:
- lib/activerecord/view/introspection/postgres.rb
Constant Summary collapse
- REGCLASS =
Arel.sql 'regclass'
- PG_TRUE =
Arel.sql 'true'
- PG_FALSE =
Arel.sql 'false'
- NOT_A_VIEW =
Arel::Nodes.build_quoted 'Not a view'
Instance Method Summary collapse
- #catch_undefined_table ⇒ Object private
- #fetch_view_definition_query(view_name, **options) ⇒ Object
- #nullify_if_not_view(expression) ⇒ Arel::Nodes::NamedFunction private
- #pg_get_viewdef(view_name, pretty: false, **options) ⇒ Arel::Nodes::NamedFunction private
Methods inherited from Abstract
#arel_cast, #arel_fn, #arel_quoted, #arel_quoted?, #default_connection, #definition_for, #inspect, #process_view_definition, #select_manager, #views
Instance Method Details
#catch_undefined_table ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/activerecord/view/introspection/postgres.rb', line 31 def catch_undefined_table yield rescue ActiveRecord::StatementInvalid => e if e.original_exception.kind_of? PG::UndefinedTable raise e if raise_error? nil else # :nocov: raise e # :nocov: end end |
#fetch_view_definition_query(view_name, **options) ⇒ Object
12 13 14 |
# File 'lib/activerecord/view/introspection/postgres.rb', line 12 def fetch_view_definition_query(view_name, **) select_manager.project nullify_if_not_view pg_get_viewdef(view_name, **) end |
#nullify_if_not_view(expression) ⇒ Arel::Nodes::NamedFunction
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/activerecord/view/introspection/postgres.rb', line 26 def nullify_if_not_view(expression) arel_fn 'NULLIF', expression, NOT_A_VIEW end |
#pg_get_viewdef(view_name, pretty: false, **options) ⇒ Arel::Nodes::NamedFunction
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 |
# File 'lib/activerecord/view/introspection/postgres.rb', line 18 def pg_get_viewdef(view_name, pretty: false, **) pretty_bool = pretty ? PG_TRUE : PG_FALSE arel_fn 'pg_get_viewdef', arel_cast(view_name, REGCLASS), pretty_bool end |