Class: Jaql::SqlGeneration::RunnableQuery
- Extended by:
- RunnableQueryFactoryMethods
- Defined in:
- lib/jaql/sql_generation/runnable_query.rb
Overview
A RunnableQuery extends Query with the ability to produce JSON from postgres by applying spec to scope
Direct Known Subclasses
Defined Under Namespace
Classes: Context
Constant Summary collapse
- JSON_RESULT_COL_NAME =
Run the query and produce JSON
'json_data'.freeze
Constants inherited from Query
Query::ARRAY_RETURN_TYPE, Query::ROW_RETURN_TYPE
Instance Attribute Summary
Attributes inherited from Query
Instance Method Summary collapse
-
#initialize(scope, spec, resolver) ⇒ RunnableQuery
constructor
A new instance of RunnableQuery.
- #json_array ⇒ Object
- #json_row ⇒ Object
- #run_returning(return_type) ⇒ Object
Methods included from RunnableQueryFactoryMethods
Methods inherited from Query
#fields_sql, #json_array_sql, #json_row_sql, #json_sql, #scope_options
Constructor Details
#initialize(scope, spec, resolver) ⇒ RunnableQuery
12 13 14 15 16 |
# File 'lib/jaql/sql_generation/runnable_query.rb', line 12 def initialize(scope, spec, resolver) @scope = scope super(Context.new, spec, resolver) end |
Instance Method Details
#json_array ⇒ Object
21 22 23 |
# File 'lib/jaql/sql_generation/runnable_query.rb', line 21 def json_array run_returning ARRAY_RETURN_TYPE end |
#json_row ⇒ Object
25 26 27 |
# File 'lib/jaql/sql_generation/runnable_query.rb', line 25 def json_row run_returning ROW_RETURN_TYPE end |
#run_returning(return_type) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/jaql/sql_generation/runnable_query.rb', line 29 def run_returning(return_type) select_sql = scope_selected_sql sql_to_run = json_sql(select_sql, JSON_RESULT_COL_NAME, return_type) puts "\n\n****************************** sql_to_run:\n#{sql_to_run} \n" run(sql_to_run, JSON_RESULT_COL_NAME) end |