abstract-sql 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/abstract-sql/transform/statement.rb +5 -1
- data/lib/abstract-sql/version.rb +1 -1
- data/test/test_abstract.rb +7 -1
- metadata +16 -16
@@ -20,6 +20,11 @@ module SQL
|
|
20
20
|
{ String(z).to_sym => { operator(op) => x } }
|
21
21
|
end
|
22
22
|
|
23
|
+
# Very simple criterion
|
24
|
+
rule({:lstatement => subtree(:l)}) do
|
25
|
+
l
|
26
|
+
end
|
27
|
+
|
23
28
|
# Statement right or left without right leaf
|
24
29
|
rule(:lstatement => { :lstatement => subtree(:y) })do
|
25
30
|
{:lstatement => y }
|
@@ -50,7 +55,6 @@ module SQL
|
|
50
55
|
{:lstatement => l, :boolean_operator => operator(op), :rstatement => r}
|
51
56
|
end
|
52
57
|
|
53
|
-
|
54
58
|
rule(:boolean_operator => simple(:op), :lstatement => subtree(:l), :rstatement => subtree(:r) ) do
|
55
59
|
{operator(op) => [l, r] }
|
56
60
|
end
|
data/lib/abstract-sql/version.rb
CHANGED
data/test/test_abstract.rb
CHANGED
@@ -6,9 +6,16 @@ class TestAbstract < Test::Unit::TestCase
|
|
6
6
|
@abstract = SQL::Abstract.new
|
7
7
|
end
|
8
8
|
|
9
|
+
|
10
|
+
test "parse very simple condition" do
|
11
|
+
assert_equal({ :criterion_13 => {:"-<=" => 8} }, @abstract.parse("criterion_13 <= 8"))
|
12
|
+
assert_equal({ :criterion_13 => {:"-<=" => 8} }, @abstract.parse("(criterion_13 <= 8)"))
|
13
|
+
end
|
14
|
+
|
9
15
|
test "parse a simple condition" do
|
10
16
|
assert_equal( {:"-and" => [{:id => { :"-=" => 1}}, {:label => {:"-like" => '%webo%'}}]}, @abstract.parse("id = 1 and label like '%webo%'"))
|
11
17
|
assert_equal( {:"-and" => [{:id => { :"-=" => 1}}, {:label => {:"-like" => '%webo%'}}]}, @abstract.parse("((id = 1 )) and label like '%webo%'"))
|
18
|
+
assert_equal({:"-and" => [{ :criterion_13 => {:"-<=" => 8} },{ :age => {:"->=" => 5} }]}, @abstract.parse("(criterion_13 <= 8) and age >= 5"))
|
12
19
|
end
|
13
20
|
|
14
21
|
test "parse a complex condition" do
|
@@ -33,7 +40,6 @@ class TestAbstract < Test::Unit::TestCase
|
|
33
40
|
},
|
34
41
|
@abstract.parse("( criterion_7 >= 8 or criterion_1 < 8 ) and ( segment_1 < 4 or not segment_2 < 1 )")
|
35
42
|
)
|
36
|
-
|
37
43
|
end
|
38
44
|
|
39
45
|
test "raise error when bad formatted sql" do
|
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: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hallelujah
|
@@ -15,12 +15,13 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-08 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: parslet
|
23
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
25
|
none: false
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
@@ -29,12 +30,12 @@ dependencies:
|
|
29
30
|
segments:
|
30
31
|
- 0
|
31
32
|
version: "0"
|
32
|
-
prerelease: false
|
33
|
-
requirement: *id001
|
34
33
|
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: test-unit
|
37
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
39
|
none: false
|
39
40
|
requirements:
|
40
41
|
- - ">="
|
@@ -45,12 +46,12 @@ dependencies:
|
|
45
46
|
- 1
|
46
47
|
- 0
|
47
48
|
version: 2.1.0
|
48
|
-
prerelease: false
|
49
|
-
requirement: *id002
|
50
49
|
type: :development
|
50
|
+
version_requirements: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: rcov
|
53
|
-
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
55
|
none: false
|
55
56
|
requirements:
|
56
57
|
- - ">="
|
@@ -59,12 +60,12 @@ dependencies:
|
|
59
60
|
segments:
|
60
61
|
- 0
|
61
62
|
version: "0"
|
62
|
-
prerelease: false
|
63
|
-
requirement: *id003
|
64
63
|
type: :development
|
64
|
+
version_requirements: *id003
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
66
|
name: rake
|
67
|
-
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
69
|
none: false
|
69
70
|
requirements:
|
70
71
|
- - ">="
|
@@ -73,9 +74,8 @@ dependencies:
|
|
73
74
|
segments:
|
74
75
|
- 0
|
75
76
|
version: "0"
|
76
|
-
prerelease: false
|
77
|
-
requirement: *id004
|
78
77
|
type: :development
|
78
|
+
version_requirements: *id004
|
79
79
|
description: It reverse an SQL statement to a Perl SQL::Abstract JSON format.
|
80
80
|
email:
|
81
81
|
- hery@rails-royce.org
|