Class: Card::Query::CardQuery
- Inherits:
-
AbstractQuery
- Object
- AbstractQuery
- Card::Query::CardQuery
- Includes:
- Conjunctions, Custom, 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/custom.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, Custom, 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
Constants inherited from AbstractQuery
AbstractQuery::ROOT_VAR_DEFAULTS
Instance Attribute Summary
Attributes inherited from AbstractQuery
#comment, #conditions, #conditions_on_join, #joins, #mods, #negate, #statement, #subqueries, #superquery, #table_suffix, #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 Custom
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 Interpretation
#bad_attribute!, #deprecated_attribute, #interpret, #interpret_as_content?, #interpret_as_modifier?, #interpret_attributes, #interpret_item, #interpret_modifier, #no_method_for_attribute_type, #relate, #relate_compound
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, #key_result, #large_list, #name_result, #process_name, #raw_result, #result_method, #return_list, #return_simple, #run, #run_sql, #seed_cache, #simple_result?
Methods included from Clause
#connection, #quote, #safe_sql
Methods inherited from AbstractQuery
#context, #depth, #interpret, #root, #root?, #sql, #sql_statement, #subquery
Methods included from AbstractQuery::Tie
#fasten, #fasten_tie, #id_from_val, #inherit_fasten, #left_join?, #list_of_ids?, #negate_join, #op_and_id_or_ids_from_val, #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, #subqueries_with_fasten, #table_alias, #table_seq
Constructor Details
#initialize(statement, comment = nil) ⇒ CardQuery
Returns a new instance of CardQuery.
34 35 36 37 38 |
# File 'lib/card/query/card_query.rb', line 34 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)
22 23 24 |
# File 'lib/card/query/card_query.rb', line 22 def self.viewable_sql Card::Query::SqlStatement.new.("cards") end |
Instance Method Details
#default_comment ⇒ Object
40 41 42 43 44 |
# File 'lib/card/query/card_query.rb', line 40 def default_comment return if @superquery || !Card.config.sql_comments statement.to_s end |
#full? ⇒ Boolean
55 56 57 |
# File 'lib/card/query/card_query.rb', line 55 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.…
51 52 53 |
# File 'lib/card/query/card_query.rb', line 51 def limit mods[:limit].to_i end |
#table ⇒ Object
26 27 28 |
# File 'lib/card/query/card_query.rb', line 26 def table "cards" end |
#table_prefix ⇒ Object
30 31 32 |
# File 'lib/card/query/card_query.rb', line 30 def table_prefix "c" end |