rebel 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rebel/sql.rb +26 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f16218bb6a1d9a787e819c1443820e5b43ea0add
|
4
|
+
data.tar.gz: 69b62d3801ac06156ad5ac356234550a7541fc3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66f5c629576b76c444e65132f910185b36f1386b251a9dfbd832dd5e78cc5c67318252175c4535bcc9c5da659ad79df0e1b25499c2fa300f103583b419a4865e
|
7
|
+
data.tar.gz: 9311d2677d3c2129b3bb2555b81e0d32359b8ffe42988165d1828a47be954c837fc515ab38a231d079213618f10d39911b2ec4934a22e01589a6f9db774b10be
|
data/lib/rebel/sql.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
1
3
|
module Rebel::SQLQ
|
2
4
|
attr_reader :conn
|
3
5
|
|
@@ -115,26 +117,22 @@ module Rebel
|
|
115
117
|
alias | or
|
116
118
|
|
117
119
|
def eq(n)
|
118
|
-
|
119
|
-
when nil
|
120
|
-
sql.raw("#{self} IS NULL")
|
121
|
-
else
|
122
|
-
sql.raw("#{self} = #{sql.name_or_value(n)}")
|
123
|
-
end
|
120
|
+
sql.raw("#{self} = #{sql.name_or_value(n)}")
|
124
121
|
end
|
125
122
|
alias == eq
|
126
|
-
|
123
|
+
|
124
|
+
def is(n)
|
125
|
+
sql.raw("#{self} IS #{sql.name_or_value(n)}")
|
126
|
+
end
|
127
127
|
|
128
128
|
def ne(n)
|
129
|
-
|
130
|
-
when nil
|
131
|
-
sql.raw("#{self} IS NOT NULL")
|
132
|
-
else
|
133
|
-
sql.raw("#{self} != #{sql.name_or_value(n)}")
|
134
|
-
end
|
129
|
+
sql.raw("#{self} != #{sql.name_or_value(n)}")
|
135
130
|
end
|
136
131
|
alias != ne
|
137
|
-
|
132
|
+
|
133
|
+
def is_not(n)
|
134
|
+
sql.raw("#{self} IS NOT #{sql.name_or_value(n)}")
|
135
|
+
end
|
138
136
|
|
139
137
|
def lt(n)
|
140
138
|
sql.raw("#{self} < #{sql.name_or_value(n)}")
|
@@ -285,9 +283,10 @@ module Rebel
|
|
285
283
|
|
286
284
|
## Support
|
287
285
|
|
288
|
-
def name(name)
|
286
|
+
def name(name = nil)
|
287
|
+
super() if name.nil? # workaround for pry and introspection
|
289
288
|
return name if name.is_a?(Raw)
|
290
|
-
return raw('*') if name ==
|
289
|
+
return raw('*') if name == :*
|
291
290
|
|
292
291
|
raw(name.to_s.split('.').map { |e| "#{@identifier_quote}#{e}#{@identifier_quote}" }.join('.'))
|
293
292
|
end
|
@@ -340,6 +339,8 @@ module Rebel
|
|
340
339
|
case right
|
341
340
|
when Array
|
342
341
|
name(left).in(*right)
|
342
|
+
when nil
|
343
|
+
name(left).is(name_or_value(right))
|
343
344
|
else
|
344
345
|
name(left).eq(name_or_value(right))
|
345
346
|
end
|
@@ -402,6 +403,15 @@ module Rebel
|
|
402
403
|
|
403
404
|
extend Rebel::SQLB
|
404
405
|
include Rebel::SQLQ
|
406
|
+
|
407
|
+
def self.name(name = nil)
|
408
|
+
return "Rebel::SQL" if name.nil?
|
409
|
+
super
|
410
|
+
end
|
411
|
+
|
412
|
+
def self.inspect
|
413
|
+
"#<Rebel::SQL(#{instance_variables.map { |k| "#{k.to_s.sub(/^@/, '')}: #{instance_variable_get(k).inspect}" }.join(', ')})>"
|
414
|
+
end
|
405
415
|
end
|
406
416
|
|
407
417
|
return sql.instance_eval(&block) unless block.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rebel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loic Nageleisen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: SQL-flavoured Ruby, or is it the other way around?
|
14
14
|
email: loic.nageleisen@gmail.com
|