Class: OrientDB::SQL::Query
- Inherits:
-
Object
- Object
- OrientDB::SQL::Query
- Extended by:
- UtilsMixin
- Includes:
- ConditionsParametersMixin, UtilsMixin
- Defined in:
- lib/orientdb/sql/query.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#limit(max_records) ⇒ Object
(also: #limit!)
readonly
Returns the value of attribute limit.
-
#lower_range ⇒ Object
readonly
Returns the value of attribute lower_range.
-
#order(*args) ⇒ Object
readonly
Returns the value of attribute order.
-
#plan ⇒ Object
readonly
Returns the value of attribute plan.
-
#projections ⇒ Object
readonly
Returns the value of attribute projections.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
-
#upper_range ⇒ Object
readonly
Returns the value of attribute upper_range.
Instance Method Summary collapse
- #from(*args) ⇒ Object
- #from!(*args) ⇒ Object
-
#initialize ⇒ Query
constructor
A new instance of Query.
- #order!(*args) ⇒ Object
- #range(lower_rid, upper_rid = nil) ⇒ Object (also: #range!)
- #select(*args) ⇒ Object (also: #columns)
- #select!(*args) ⇒ Object
- #to_s ⇒ Object
- #to_sql_query ⇒ Object
Methods included from UtilsMixin
field_name, quote, quote_regexp, quote_string, select_single_string
Methods included from ConditionsParametersMixin
#and, #and_not, #or, #or_not, #where, #where!
Constructor Details
#initialize ⇒ Query
Returns a new instance of Query.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/orientdb/sql/query.rb', line 9 def initialize @projections = [] @targets = [] @conditions = [] @order = [] @limit = nil @lower_range = nil @upper_range = nil @plan = nil end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
7 8 9 |
# File 'lib/orientdb/sql/query.rb', line 7 def conditions @conditions end |
#limit(max_records) ⇒ Object (readonly) Also known as: limit!
Returns the value of attribute limit.
7 8 9 |
# File 'lib/orientdb/sql/query.rb', line 7 def limit @limit end |
#lower_range ⇒ Object (readonly)
Returns the value of attribute lower_range.
7 8 9 |
# File 'lib/orientdb/sql/query.rb', line 7 def lower_range @lower_range end |
#order(*args) ⇒ Object (readonly)
Returns the value of attribute order.
7 8 9 |
# File 'lib/orientdb/sql/query.rb', line 7 def order @order end |
#plan ⇒ Object (readonly)
Returns the value of attribute plan.
7 8 9 |
# File 'lib/orientdb/sql/query.rb', line 7 def plan @plan end |
#projections ⇒ Object (readonly)
Returns the value of attribute projections.
7 8 9 |
# File 'lib/orientdb/sql/query.rb', line 7 def projections @projections end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
7 8 9 |
# File 'lib/orientdb/sql/query.rb', line 7 def targets @targets end |
#upper_range ⇒ Object (readonly)
Returns the value of attribute upper_range.
7 8 9 |
# File 'lib/orientdb/sql/query.rb', line 7 def upper_range @upper_range end |
Instance Method Details
#from(*args) ⇒ Object
46 47 48 49 |
# File 'lib/orientdb/sql/query.rb', line 46 def from(*args) args.each { |x| @targets << x.to_s } self end |
#from!(*args) ⇒ Object
51 52 53 54 |
# File 'lib/orientdb/sql/query.rb', line 51 def from!(*args) @targets = [] from *args end |
#order!(*args) ⇒ Object
75 76 77 78 |
# File 'lib/orientdb/sql/query.rb', line 75 def order!(*args) @order = [] order *args end |
#range(lower_rid, upper_rid = nil) ⇒ Object Also known as: range!
87 88 89 90 91 |
# File 'lib/orientdb/sql/query.rb', line 87 def range(lower_rid, upper_rid = nil) @lower_range = lower_rid.to_s @upper_range = upper_rid ? upper_rid.to_s : nil self end |
#select(*args) ⇒ Object Also known as: columns
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/orientdb/sql/query.rb', line 20 def select(*args) args.each do |arg| case arg when String, Symbol, Integer arg = select_single_string(arg) @projections << arg when Hash arg.each { |k, v| @projections << "#{k} AS #{v}" } when Array if arg.size == 2 @projections << "#{arg.first} AS #{arg.last}" else arg.each { |x| @projections << select_single_string(x) } end end end self end |
#select!(*args) ⇒ Object
41 42 43 44 |
# File 'lib/orientdb/sql/query.rb', line 41 def select!(*args) @projections = [] select *args end |
#to_s ⇒ Object
95 96 97 |
# File 'lib/orientdb/sql/query.rb', line 95 def to_s (select_sql + target_sql + conditions_sql + order_sql + limit_sql + range_sql).strip end |
#to_sql_query ⇒ Object
99 100 101 |
# File 'lib/orientdb/sql/query.rb', line 99 def to_sql_query OrientDB::SQLSynchQuery.new to_s end |