This repository has been archived by the owner on Mar 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 215
/
function.rb
57 lines (48 loc) · 1.52 KB
/
function.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module Squeel
module Nodes
# A node that represents an SQL function call
class Function
include PredicateMethods
include PredicateOperators
include Operators
include Ordering
include Aliasing
alias :== :eq
alias :'^' :not_eq
alias :'!=' :not_eq if respond_to?(:'!=')
alias :>> :in
alias :<< :not_in
alias :=~ :matches
alias :'!~' :does_not_match if respond_to?(:'!~')
alias :> :gt
alias :>= :gteq
alias :< :lt
alias :<= :lteq
# @return [Symbol] The name of the SQL function to be called
attr_reader :name
# @return [Array] The arguments to be passed to the SQL function
attr_reader :args
# Create a node representing an SQL Function with the given name and arguments
# @param [Symbol] name The function name
# @param [Array] args The array of arguments to pass to the function.
def initialize(name, args)
@name, @args = name, args
end
# expand_hash_conditions_for_aggregates assumes our hash keys can be
# converted to symbols, so this has to be implemented, but it doesn't
# really have to do anything useful.
# @return [NilClass] Just to avoid bombing out on expand_hash_conditions_for_aggregates
def to_sym
nil
end
def hash
[@name, @args].hash
end
def eql?(other)
self.class == other.class &&
self.name.eql?(other.name) &&
self.args.eql?(other.args)
end
end
end
end