Sha256: 64f5d3ffc0369f4ecb7bc6bf9a5e27bd6a60d06ad86715de2b02a04bd753b1f6

Contents?: true

Size: 1.23 KB

Versions: 39

Compression:

Stored size: 1.23 KB

Contents

module Bmg
  module Sql
    module SelectList
      include Expr

      def desaliaser(for_predicate = false)
        ->(a){
          item = sexpr_body.find{|item| item.as_name.to_s == a.to_s }
          return nil unless left = item && item.left
          return left unless for_predicate
          case left.first
          when :literal
            Predicate::Grammar.sexpr([:literal, left.last])
          when :qualified_name
            Predicate::Grammar.sexpr([:qualified_identifier, left.qualifier.to_sym, left.as_name.to_sym])
          else
            raise "Unexpected select_item `#{left}`"
          end
        }
      end

      def is_table_dee?
        Builder::IS_TABLE_DEE == self
      end

      def has_computed_attributes?
        sexpr_body.any?{|item| item.is_computed? }
      end

      def knows?(as_name)
        find_child{|child| child.as_name == as_name }
      end

      def to_attr_list
        sexpr_body.map{|a| a.as_name.to_sym }
      end

      def to_sql(buffer, dialect)
        sexpr_body.each_with_index do |item,index|
          buffer << COMMA << SPACE unless index == 0
          item.to_sql(buffer, dialect)
        end
        buffer
      end

    end # module SelectList
  end # module Sql
end # module Bmg

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
bmg-0.18.13 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.12 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.11 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.10 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.9 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.8 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.7 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.6 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.5 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.4 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.3 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.2 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.1 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.0 lib/bmg/sql/nodes/select_list.rb
bmg-0.17.8 lib/bmg/sql/nodes/select_list.rb
bmg-0.17.7 lib/bmg/sql/nodes/select_list.rb
bmg-0.17.6 lib/bmg/sql/nodes/select_list.rb
bmg-0.17.5 lib/bmg/sql/nodes/select_list.rb
bmg-0.17.4 lib/bmg/sql/nodes/select_list.rb