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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7de70ccbf6676684b58192eeb8801799bc4b045d
4
- data.tar.gz: 67a793c131ce5ca49d099d8bbccccda3f8e5f9da
3
+ metadata.gz: bd5bc10f535f5916950818be427599c4a72f77f7
4
+ data.tar.gz: 9c9ef2ebc0988d47626bda36b7a4b842965f4b0a
5
5
  SHA512:
6
- metadata.gz: 344a891cb2325191454bc29d05f18f963a17dbad7aad7e3875ab43cca71ab1512ca530a4a2ad8509301bdd48b98dbcddffb2a5b5a5889798ace858aa6636b87e
7
- data.tar.gz: db12ee071da15bb594a64724cf72c3922c4df3f8ec0a3aed7f2e8ae44afa34df6bf9cf1dcae77479308d57bf954b6ba5a244476febd839b159c42e9ba88db7c0
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
- "#{left.to_s} = #{convert_value(self.right)}"
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
- "#{left.to_s} != #{convert_value(self.right)}"
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
- indent = " "*indent_level
61
- indent_out = " "*(indent_level-1)
62
- "(\n" + indent + self.conditions.map{ |c| c.to_s(indent_level: indent_level+1) }.join("\n#{indent}#{self.type.to_s.upcase} ") + "\n#{indent_out})"
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
@@ -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(BasicCondition, condition.class) unless condition.is_a?(BasicCondition)
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
@@ -1,3 +1,3 @@
1
1
  module Rusql
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rusql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ajith Hussain