Sha256: fd87d8df9d66b48ecbec7a37caf2ad0073d6f60cf219c12b898dc8c8a7e4d59f

Contents?: true

Size: 693 Bytes

Versions: 5

Compression:

Stored size: 693 Bytes

Contents

module Alf
  class Predicate
    module In

      def subquery?
        Sql::Expr === last
      end

      def subquery
        subquery? ? last : nil
      end

      def to_sql(buffer = "")
        identifier.to_sql(buffer)
        buffer << Sql::Expr::SPACE << Sql::Expr::IN << Sql::Expr::SPACE
        if subquery?
          values.to_sql(buffer)
        else
          buffer << Sql::Expr::LEFT_PARENTHESE
          values.each_with_index do |val,index|
            buffer << Sql::Expr::COMMA << Sql::Expr::SPACE unless index==0
            to_sql_literal(buffer, val)
          end
          buffer << Sql::Expr::RIGHT_PARENTHESE
        end
        buffer
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-sql-0.16.3 lib/alf/predicate/nodes/in.rb
alf-sql-0.16.2 lib/alf/predicate/nodes/in.rb
alf-sql-0.16.1 lib/alf/predicate/nodes/in.rb
alf-sql-0.16.0 lib/alf/predicate/nodes/in.rb
alf-sql-0.15.0 lib/alf/predicate/nodes/in.rb