Module: Card::Query::AbstractQuery::QueryHelper
- Included in:
- Card::Query::AbstractQuery
- Defined in:
- lib/card/query/abstract_query/query_helper.rb
Overview
shared methods for queries
Instance Method Summary collapse
- #add_condition(*args) ⇒ Object
- #current_conjunction ⇒ Object
- #direct_subqueries ⇒ Object
- #fld(field_name) ⇒ Object
- #subqueries_with_fasten(fasten) ⇒ Object
- #table_alias ⇒ Object
- #table_seq ⇒ Object
Instance Method Details
#add_condition(*args) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/card/query/abstract_query/query_helper.rb', line 39 def add_condition *args @conditions << if args.size > 1 [args.shift, Query::Value.new(args.shift, self)] else args[0] end end |
#current_conjunction ⇒ Object
48 49 50 |
# File 'lib/card/query/abstract_query/query_helper.rb', line 48 def current_conjunction "AND" end |
#direct_subqueries ⇒ Object
6 7 8 |
# File 'lib/card/query/abstract_query/query_helper.rb', line 6 def direct_subqueries subqueries_with_fasten :direct end |
#fld(field_name) ⇒ Object
35 36 37 |
# File 'lib/card/query/abstract_query/query_helper.rb', line 35 def fld field_name "#{table_alias}.#{field_name}" end |
#subqueries_with_fasten(fasten) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/card/query/abstract_query/query_helper.rb', line 10 def subqueries_with_fasten fasten list = [] subqueries.each do |s| next unless Array.wrap(fasten).include? s.fasten list << s list += s.subqueries_with_fasten s.fasten end list end |
#table_alias ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/card/query/abstract_query/query_helper.rb', line 21 def table_alias @table_alias ||= begin if fasten == :direct @superquery.table_alias else "#{table_prefix}#{root.table_seq}#{@table_suffix}" end end end |
#table_seq ⇒ Object
31 32 33 |
# File 'lib/card/query/abstract_query/query_helper.rb', line 31 def table_seq @table_seq = @table_seq ? (@table_seq + 1) : 0 end |