abstract-sql 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/abstract-sql/parser/statement.rb +2 -2
- data/lib/abstract-sql/version.rb +1 -1
- data/test/test_abstract.rb +3 -2
- metadata +4 -4
@@ -9,7 +9,7 @@ module SQL
|
|
9
9
|
rule(:spaces?){ spaces.maybe}
|
10
10
|
rule(:digit) { match('[0-9]') }
|
11
11
|
rule(:int){ digit.repeat(1).as(:int) }
|
12
|
-
rule(:bool_not) { spaces >> (str('not') | str('NOT')).as(:not) >> spaces}
|
12
|
+
rule(:bool_not) { spaces? >> (str('not') | str('NOT')).as(:not) >> spaces?}
|
13
13
|
|
14
14
|
rule(:float) do
|
15
15
|
(str('-').maybe >> (
|
@@ -48,7 +48,7 @@ module SQL
|
|
48
48
|
end
|
49
49
|
|
50
50
|
rule(:entity) do
|
51
|
-
bool_not.maybe >> (value.as(:lvalue) >> operator >> value.as(:rvalue))
|
51
|
+
bool_not.maybe >> ((lparen >> entity >> rparen) | (value.as(:lvalue) >> operator >> value.as(:rvalue)))
|
52
52
|
end
|
53
53
|
|
54
54
|
rule(:statement) do
|
data/lib/abstract-sql/version.rb
CHANGED
data/test/test_abstract.rb
CHANGED
@@ -10,6 +10,7 @@ class TestAbstract < Test::Unit::TestCase
|
|
10
10
|
test "parse very simple condition" do
|
11
11
|
assert_equal({ :criterion_13 => {:"-<=" => 8} }, @abstract.parse("criterion_13 <= 8"))
|
12
12
|
assert_equal({ :criterion_13 => {:"-<=" => 8} }, @abstract.parse("(criterion_13 <= 8)"))
|
13
|
+
assert_equal({ :"-not_bool" => { :criterion_13 => {:"-<=" => 8} } }, @abstract.parse("not (criterion_13 <= 8)"))
|
13
14
|
end
|
14
15
|
|
15
16
|
test "parse a simple condition" do
|
@@ -19,13 +20,13 @@ class TestAbstract < Test::Unit::TestCase
|
|
19
20
|
end
|
20
21
|
|
21
22
|
test "parse a complex condition" do
|
22
|
-
assert_equal(
|
23
|
+
assert_equal(
|
23
24
|
{
|
24
25
|
:"-or" => [
|
25
26
|
{:"-and" => [{:id => { :"-=" => 1}}, {:label => {:"-like" => '%webo%'}}]},
|
26
27
|
{:"-and" => [{:id => { :"-!=" => 1}}, {:label => {:"-like" => '%api%'}}]}
|
27
28
|
]
|
28
|
-
},
|
29
|
+
},
|
29
30
|
@abstract.parse("(id = 1 AND label like '%webo%') OR (id !=1 and label like '%api%')")
|
30
31
|
)
|
31
32
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstract-sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hallelujah
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-22 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|