class Card::Query::CardQuery

interpret CQL queries, transform them into SQL, and run them.

Public Class Methods

new(statement, comment=nil) click to toggle source
Calls superclass method Card::Query::AbstractQuery::new
# File lib/card/query/card_query.rb, line 34
def initialize statement, comment=nil
  super statement
  @comment = comment || default_comment
  interpret @statement
end
viewable_sql() click to toggle source

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)

# File lib/card/query/card_query.rb, line 22
def self.viewable_sql
  Card::Query::SqlStatement.new.permission_conditions("cards")
end

Public Instance Methods

default_comment() click to toggle source
# File lib/card/query/card_query.rb, line 40
def default_comment
  return if @superquery || !Card.config.sql_comments

  statement.to_s
end
full?() click to toggle source
# File lib/card/query/card_query.rb, line 55
def full?
  !superquery && mods[:return] != "count"
end
limit() click to toggle source

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.…

# File lib/card/query/card_query.rb, line 51
def limit
  mods[:limit].to_i
end
table() click to toggle source
# File lib/card/query/card_query.rb, line 26
def table
  "cards"
end
table_prefix() click to toggle source
# File lib/card/query/card_query.rb, line 30
def table_prefix
  "c"
end