Sha256: deb62c20213f6833c097c64a8f458a5a158239de8fedb0e4876c11f0916b8a82

Contents?: true

Size: 1.41 KB

Versions: 7

Compression:

Stored size: 1.41 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
      # 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

7 entries across 7 versions & 1 rubygems

Version Path
card-1.96.8 lib/card/query/card_query.rb
card-1.96.7 lib/card/query/card_query.rb
card-1.96.6 lib/card/query/card_query.rb
card-1.96.5 lib/card/query/card_query.rb
card-1.96.4 lib/card/query/card_query.rb
card-1.96.3 lib/card/query/card_query.rb
card-1.96.2 lib/card/query/card_query.rb