sql-parser2 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sql-parser/parser.racc +5 -1
- data/lib/sql-parser/parser.racc.rb +759 -745
- data/lib/sql-parser/parser.rex +1 -0
- data/lib/sql-parser/parser.rex.rb +3 -0
- data/lib/sql-parser/sql_visitor.rb +6 -1
- data/lib/sql-parser/statement.rb +13 -1
- data/lib/sql-parser/version.rb +1 -1
- metadata +1 -1
data/lib/sql-parser/parser.rex
CHANGED
@@ -43,7 +43,8 @@ module SQLParser
|
|
43
43
|
def visit_DirectSelect(o)
|
44
44
|
[
|
45
45
|
o.query_expression,
|
46
|
-
o.order_by
|
46
|
+
o.order_by,
|
47
|
+
o.limit_clause
|
47
48
|
].compact.collect { |e| visit(e) }.join(' ')
|
48
49
|
end
|
49
50
|
|
@@ -51,6 +52,10 @@ module SQLParser
|
|
51
52
|
"ORDER BY #{arrayize(o.sort_specification)}"
|
52
53
|
end
|
53
54
|
|
55
|
+
def visit_Limit(o)
|
56
|
+
"LIMIT #{o.limit_count}"
|
57
|
+
end
|
58
|
+
|
54
59
|
def visit_Subquery(o)
|
55
60
|
"(#{visit(o.query_specification)})"
|
56
61
|
end
|
data/lib/sql-parser/statement.rb
CHANGED
@@ -80,13 +80,15 @@ module SQLParser
|
|
80
80
|
|
81
81
|
class DirectSelect < Node
|
82
82
|
|
83
|
-
def initialize(query_expression, order_by)
|
83
|
+
def initialize(query_expression, order_by, limit_clause = nil)
|
84
84
|
@query_expression = query_expression
|
85
85
|
@order_by = order_by
|
86
|
+
@limit_clause = limit_clause
|
86
87
|
end
|
87
88
|
|
88
89
|
attr_reader :query_expression
|
89
90
|
attr_reader :order_by
|
91
|
+
attr_reader :limit_clause
|
90
92
|
|
91
93
|
end
|
92
94
|
|
@@ -100,6 +102,16 @@ module SQLParser
|
|
100
102
|
|
101
103
|
end
|
102
104
|
|
105
|
+
class Limit < Node
|
106
|
+
|
107
|
+
def initialize(limit_count)
|
108
|
+
@limit_count = limit_count
|
109
|
+
end
|
110
|
+
|
111
|
+
attr_reader :limit_count
|
112
|
+
|
113
|
+
end
|
114
|
+
|
103
115
|
class Subquery < Node
|
104
116
|
|
105
117
|
def initialize(query_specification)
|
data/lib/sql-parser/version.rb
CHANGED