Sha256: 1b86e506d0fe9b095b88cceedf1c4d00643dd8137be5d734213826cdf9974a2a

Contents?: true

Size: 1.43 KB

Versions: 12

Compression:

Stored size: 1.43 KB

Contents

class Card
  module Query
    # interpret CQL queries, transform them into SQL, and run them.
    class CardQuery < AbstractQuery
      include Clause
      include Run
      include MatchAttributes
      include RelationalAttributes
      include ReferenceAttributes
      include FoundBy
      include Interpretation
      include Normalization
      include Sorting
      include Conjunctions
      include Custom
      # Query Execution

      # 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)

      def self.viewable_sql
        Card::Query::SqlStatement.new.permission_conditions("cards")
      end

      def table
        "cards"
      end

      def table_prefix
        "c"
      end

      def initialize statement, comment=nil
        super statement
        @comment = comment || default_comment
        interpret @statement
      end

      def default_comment
        return if @superquery || !Card.config.sql_comments

        statement.to_s
      end

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

      def limit
        mods[:limit].to_i
      end

      def full?
        !superquery && mods[:return] != "count"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-1.108.1 lib/card/query/card_query.rb
card-1.108.0 lib/card/query/card_query.rb
card-1.107.0 lib/card/query/card_query.rb
card-1.106.0 lib/card/query/card_query.rb
card-1.105.6 lib/card/query/card_query.rb
card-1.105.5 lib/card/query/card_query.rb
card-1.105.4 lib/card/query/card_query.rb
card-1.105.3 lib/card/query/card_query.rb
card-1.105.2.pre1 lib/card/query/card_query.rb
card-1.105.2 lib/card/query/card_query.rb
card-1.105.1 lib/card/query/card_query.rb
card-1.105.0 lib/card/query/card_query.rb