rusql 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rusql/basic_condition.rb +11 -3
- data/lib/rusql/complex_condition.rb +8 -4
- data/lib/rusql/join.rb +2 -2
- data/lib/rusql/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd5bc10f535f5916950818be427599c4a72f77f7
|
4
|
+
data.tar.gz: 9c9ef2ebc0988d47626bda36b7a4b842965f4b0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a8d38ce38493e46e2576843a809e5c384d577684a7b78fd348b364ff5bce76e0859a6f77648be5f7c819a8d1362b92781e9f315ddea5a7d7a9b34886bc65399
|
7
|
+
data.tar.gz: 6d1f2381cbf760af124abab5362272eedd02c2237252afb27a78165f090587c3537ff57308ac260085b2544c87a43867ebe9484358c7ea3b521be91bcd91a9aa
|
@@ -44,10 +44,14 @@ module Rusql
|
|
44
44
|
c
|
45
45
|
end
|
46
46
|
|
47
|
-
def to_s(indent_level: 1) # to make it compatible with complex condition to_s
|
47
|
+
def to_s(indent_level: 1, multiline: true) # dummy params to make it compatible with complex condition to_s
|
48
48
|
case self.type
|
49
49
|
when :equals
|
50
|
-
|
50
|
+
if self.right.nil?
|
51
|
+
"#{left.to_s} IS NULL"
|
52
|
+
else
|
53
|
+
"#{left.to_s} = #{convert_value(self.right)}"
|
54
|
+
end
|
51
55
|
when :greater_than
|
52
56
|
"#{left.to_s} > #{convert_value(self.right)}"
|
53
57
|
when :greater_than_or_equals
|
@@ -61,7 +65,11 @@ module Rusql
|
|
61
65
|
when :like
|
62
66
|
"#{left.to_s} LIKE #{convert_value(self.right)}"
|
63
67
|
when :not_equals
|
64
|
-
|
68
|
+
if self.right.nil?
|
69
|
+
"#{left.to_s} IS NOT NULL"
|
70
|
+
else
|
71
|
+
"#{left.to_s} != #{convert_value(self.right)}"
|
72
|
+
end
|
65
73
|
when :not_in
|
66
74
|
"#{left.to_s} NOT IN (#{ self.right.map{|v| convert_value(v) }.join(", ") })"
|
67
75
|
end
|
@@ -56,10 +56,14 @@ module Rusql
|
|
56
56
|
new_condition
|
57
57
|
end
|
58
58
|
|
59
|
-
def to_s(indent_level: 1)
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
def to_s(indent_level: 1, multiline: true)
|
60
|
+
if multiline
|
61
|
+
indent = " "*indent_level
|
62
|
+
indent_out = " "*(indent_level-1)
|
63
|
+
"(\n" + indent + self.conditions.map{ |c| c.to_s(indent_level: indent_level+1, multiline: true) }.join("\n#{indent}#{self.type.to_s.upcase} ") + "\n#{indent_out})"
|
64
|
+
else
|
65
|
+
self.conditions.map{ |c| c.to_s(indent_level: indent_level, multiline: multiline) }.join(" #{self.type.to_s.upcase} ")
|
66
|
+
end
|
63
67
|
end
|
64
68
|
end
|
65
69
|
end
|
data/lib/rusql/join.rb
CHANGED
@@ -15,7 +15,7 @@ module Rusql
|
|
15
15
|
|
16
16
|
raise Exception.new("Expected type to be one of #{ TYPES.map(&:to_s).join(",") }") unless TYPES.include?(type)
|
17
17
|
raise TypeException.new(Table, table.class) if final_table.nil?
|
18
|
-
raise TypeException.new(
|
18
|
+
raise TypeException.new(Condition, condition.class) unless condition.is_a?(Condition)
|
19
19
|
|
20
20
|
@type = type
|
21
21
|
@table = final_table
|
@@ -23,7 +23,7 @@ module Rusql
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def to_s
|
26
|
-
"#{ self.type.to_s.upcase.gsub("_"," ") } #{self.table.to_s_for_aliasing} ON #{self.condition.to_s}"
|
26
|
+
"#{ self.type.to_s.upcase.gsub("_"," ") } #{self.table.to_s_for_aliasing} ON #{self.condition.to_s(multiline: false) }"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/rusql/version.rb
CHANGED