Class: Sequel::SQL::Expression
Overview
Base class for all SQL fragments
Direct Known Subclasses
AliasedExpression, ColumnAll, ComplexExpression, GenericExpression, JoinClause, OrderedExpression, PlaceholderLiteralString, SQLArray, Window
Class Method Summary collapse
-
.attr_reader(*args) ⇒ Object
all instance variables declared to be readers are to be used for comparison.
- .comparison_attrs ⇒ Object
Instance Method Summary collapse
-
#==(other) ⇒ Object
Alias of eql?.
-
#eql?(other) ⇒ Boolean
Returns true if the receiver is the same expression as the the
other
expression. -
#hash ⇒ Object
Make sure that the hash value is the same if the attributes are the same.
-
#lit ⇒ Object
Returns self, because SQL::Expression already acts like LiteralString.
-
#sql_literal(ds) ⇒ Object
Alias of to_s.
Class Method Details
.attr_reader(*args) ⇒ Object
all instance variables declared to be readers are to be used for comparison.
54 55 56 57 |
# File 'lib/sequel/sql.rb', line 54 def self.attr_reader(*args) super comparison_attrs.concat args end |
.comparison_attrs ⇒ Object
59 60 61 |
# File 'lib/sequel/sql.rb', line 59 def self.comparison_attrs @comparison_attrs ||= self == Expression ? [] : superclass.comparison_attrs.clone end |
Instance Method Details
#==(other) ⇒ Object
Alias of eql?
72 73 74 |
# File 'lib/sequel/sql.rb', line 72 def ==(other) eql?(other) end |
#eql?(other) ⇒ Boolean
Returns true if the receiver is the same expression as the the other
expression.
78 79 80 |
# File 'lib/sequel/sql.rb', line 78 def eql?(other) other.is_a?(self.class) && !self.class.comparison_attrs.find {|a| send(a) != other.send(a)} end |
#hash ⇒ Object
Make sure that the hash value is the same if the attributes are the same.
83 84 85 |
# File 'lib/sequel/sql.rb', line 83 def hash ([self.class] + self.class.comparison_attrs.map{|x| send(x)}).hash end |
#lit ⇒ Object
Returns self, because SQL::Expression already acts like LiteralString.
89 90 91 |
# File 'lib/sequel/sql.rb', line 89 def lit self end |
#sql_literal(ds) ⇒ Object
Alias of to_s
94 95 96 |
# File 'lib/sequel/sql.rb', line 94 def sql_literal(ds) to_s(ds) end |