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.23.3 lib/bmg/sql/nodes/select_list.rb
bmg-0.23.2 lib/bmg/sql/nodes/select_list.rb
bmg-0.23.1 lib/bmg/sql/nodes/select_list.rb
bmg-0.23.0 lib/bmg/sql/nodes/select_list.rb
bmg-0.21.5 lib/bmg/sql/nodes/select_list.rb
bmg-0.21.4 lib/bmg/sql/nodes/select_list.rb
bmg-0.20.5 lib/bmg/sql/nodes/select_list.rb
bmg-0.19.3 lib/bmg/sql/nodes/select_list.rb
bmg-0.21.3 lib/bmg/sql/nodes/select_list.rb
bmg-0.21.2 lib/bmg/sql/nodes/select_list.rb
bmg-0.21.0 lib/bmg/sql/nodes/select_list.rb
bmg-0.20.4 lib/bmg/sql/nodes/select_list.rb
bmg-0.20.2 lib/bmg/sql/nodes/select_list.rb
bmg-0.20.1 lib/bmg/sql/nodes/select_list.rb
bmg-0.20.0 lib/bmg/sql/nodes/select_list.rb
bmg-0.19.2 lib/bmg/sql/nodes/select_list.rb
bmg-0.19.1 lib/bmg/sql/nodes/select_list.rb
bmg-0.19.0 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.15 lib/bmg/sql/nodes/select_list.rb
bmg-0.18.14 lib/bmg/sql/nodes/select_list.rb