Sha256: a497c7dfb372dcb3d67e10a02d373f6dec0452dd9035d8f4a347749511ba419f
Contents?: true
Size: 1.55 KB
Versions: 10
Compression:
Stored size: 1.55 KB
Contents
module Pacer module Filter module SqlFilter attr_accessor :sql, :select, :orient_type, :where, :query_args, :order_by, :timeout, :parallel attr_writer :limit, :offset def offset(n = nil) if n @offset = n self else @offset end end def limit(n = nil) if n @limit = n self else @limit end end protected def orient_type_name t = graph.orient_type(orient_type, element_type) if t t.name else fail Pacer::ClientError.new "Unknown orient type for #{ element_type }: #{ orient_type }" end end def query if sql s = "" s << sql else s = "SELECT " case select when String s << select when Array s << select.join(", ") end s << " FROM #{ orient_type } WHERE " s << where s << "ORDER_BY " if order_by case order_by when String s << order_by when Array s << order_by.join(", ") end end s << " SKIP #{ offset }" if offset s << " LIMIT #{ limit }" if limit s << " TIMEOUT #{ timeout }" if timeout s << " PARALLEL" if parallel s end def source_iterator graph.sql_command(query, query_args).iterator end def inspect_string "SQL '#{query}' #{query_args}" end end end end
Version data entries
10 entries across 10 versions & 1 rubygems