Class: Card::Query::CardQuery
- Inherits:
-
AbstractQuery
- Object
- AbstractQuery
- Card::Query::CardQuery
- Includes:
- Conjunctions, FoundBy, Interpretation, MatchAttributes, Normalization, ReferenceAttributes, RelationalAttributes, Run, Sorting, Clause
- Defined in:
- lib/card/query/card_query.rb,
lib/card/query/card_query/run.rb,
lib/card/query/card_query/sorting.rb,
lib/card/query/card_query/found_by.rb,
lib/card/query/card_query/conjunctions.rb,
lib/card/query/card_query/normalization.rb,
lib/card/query/card_query/interpretation.rb,
lib/card/query/card_query/match_attributes.rb,
lib/card/query/card_query/reference_attributes.rb,
lib/card/query/card_query/relational_attributes.rb
Overview
interpret CQL queries, transform them into SQL, and run them.
Defined Under Namespace
Modules: Conjunctions, FoundBy, Interpretation, MatchAttributes, Normalization, ReferenceAttributes, RelationalAttributes, Run, Sorting
Constant Summary
Constants included from Sorting
Sorting::SORT_BY_ITEM_JOIN_MAP
Constants included from Interpretation
Interpretation::INTERPRET_METHOD
Instance Attribute Summary
Attributes inherited from AbstractQuery
#comment, #conditions, #conditions_on_join, #joins, #mods, #negate, #statement, #subqueries, #superquery, #table_seq, #vars
Class Method Summary collapse
-
.viewable_sql ⇒ Object
By default a query returns card objects.
Instance Method Summary collapse
- #default_comment ⇒ Object
- #full? ⇒ Boolean
-
#initialize(statement, comment = nil) ⇒ CardQuery
constructor
A new instance of CardQuery.
-
#limit ⇒ Object
Query Hierarchy @root, @subqueries, and @superquery are used to track a hierarchy of query objects.
- #table ⇒ Object
- #table_prefix ⇒ Object
Methods included from Conjunctions
#all, #any, #current_conjunction, #not
Methods included from Sorting
#count_sort_query, #count_subselect, #join_cards, #join_count_sort_query, #sort, #sort_by, #sort_by_count, #sort_by_count_referred_to, #sort_by_item_join, #sort_by_item_join_field, #sort_method_not_implemented
Methods included from Normalization
#clause_to_hash, #normalize_array_value, #normalize_clause, #normalize_string_value, #normalize_value, #string_value_from_var
Methods included from Interpretation
#bad_attribute!, #interpret, #interpret_as_content?, #interpret_as_modifier?, #interpret_attributes, #interpret_item, #interpret_modifier, #relate, #relate_compound, #relate_multi_value
Methods included from FoundBy
Methods included from ReferenceAttributes
define_reference_method, #member, #member_of
Methods included from RelationalAttributes
#created_by, #creator_of, #edited_by, #editor_of, #last_edited_by, #last_editor_of, #left, #left_plus, #part, #plus, #right, #right_plus, #type, #updated_by, #updater_of
Methods included from MatchAttributes
#complete, #match, #name_match
Methods included from Run
#alter_result, #alter_results?, #card_result, #count_result, #default_result, #fetch_or_instantiate, #id_result, #large_list, #name_result, #process_name, #raw_result, #result_method, #return_list, #return_simple, #run, #run_sql, #simple_result?
Methods included from Clause
#connection, #quote, #safe_sql
Methods inherited from AbstractQuery
#context, #depth, #init_instance_vars, #init_query_vars, #interpret, #root, #root?, #sql, #subquery
Methods included from AbstractQuery::Tie
#fasten, #fasten_tie, #id_from_val, #inherit_fasten, #left_join?, #negate_join, #restrict, #super_conditions, #superfield, #tie, #tie_subquery, #tie_with_exist, #tie_with_in, #tie_with_join, #tie_with_join_args
Methods included from AbstractQuery::QueryHelper
#add_condition, #current_conjunction, #direct_subqueries, #fld, #next_table_suffix, #subqueries_with_fasten, #table_alias
Constructor Details
#initialize(statement, comment = nil) ⇒ CardQuery
Returns a new instance of CardQuery.
33 34 35 36 37 |
# File 'lib/card/query/card_query.rb', line 33 def initialize statement, comment=nil super statement @comment = comment || default_comment interpret @statement end |
Class Method Details
.viewable_sql ⇒ Object
By default a query returns card objects. This is accomplished by returning a card identifier from SQL and then hooking into our caching system (see Card::Fetch)
21 22 23 |
# File 'lib/card/query/card_query.rb', line 21 def self.viewable_sql Card::Query::SqlStatement.new.("cards") end |
Instance Method Details
#default_comment ⇒ Object
39 40 41 42 43 |
# File 'lib/card/query/card_query.rb', line 39 def default_comment return if @superquery || !Card.config.sql_comments statement.to_s end |
#full? ⇒ Boolean
54 55 56 |
# File 'lib/card/query/card_query.rb', line 54 def full? !superquery && mods[:return] != "count" end |
#limit ⇒ Object
Query Hierarchy @root, @subqueries, and @superquery are used to track a hierarchy of query objects. This nesting allows to find, for example, cards that link to cards that link to cards....
50 51 52 |
# File 'lib/card/query/card_query.rb', line 50 def limit mods[:limit].to_i end |
#table ⇒ Object
25 26 27 |
# File 'lib/card/query/card_query.rb', line 25 def table "cards" end |
#table_prefix ⇒ Object
29 30 31 |
# File 'lib/card/query/card_query.rb', line 29 def table_prefix "c" end |