@@ -12,7 +12,9 @@ use nom::sequence::{delimited, terminated, tuple};
12
12
use base:: column:: Column ;
13
13
use base:: FieldDefinitionExpression ;
14
14
use base:: table:: Table ;
15
- use common:: { JoinConstraint , JoinOperator , JoinRightSide , OrderClause , statement_terminator, unsigned_number} ;
15
+ use common:: {
16
+ JoinConstraint , JoinOperator , JoinRightSide , OrderClause , statement_terminator, unsigned_number,
17
+ } ;
16
18
use common:: condition:: ConditionExpression ;
17
19
18
20
#[ derive( Clone , Debug , Default , Eq , Hash , PartialEq , Serialize , Deserialize ) ]
@@ -126,7 +128,7 @@ impl GroupByClause {
126
128
pub fn parse ( i : & str ) -> IResult < & str , GroupByClause , VerboseError < & str > > {
127
129
let ( remaining_input, ( _, _, _, columns, having) ) = tuple ( (
128
130
multispace0,
129
- tag_no_case ( "group by " ) ,
131
+ tag_no_case ( "GROUP BY " ) ,
130
132
multispace1,
131
133
Column :: field_list,
132
134
opt ( ConditionExpression :: having_clause) ,
@@ -166,7 +168,7 @@ impl JoinClause {
166
168
pub fn parse ( i : & str ) -> IResult < & str , JoinClause , VerboseError < & str > > {
167
169
let ( remaining_input, ( _, _natural, operator, _, right, _, constraint) ) = tuple ( (
168
170
multispace0,
169
- opt ( terminated ( tag_no_case ( "natural " ) , multispace1) ) ,
171
+ opt ( terminated ( tag_no_case ( "NATURAL " ) , multispace1) ) ,
170
172
JoinOperator :: parse,
171
173
multispace1,
172
174
JoinRightSide :: parse,
@@ -204,15 +206,26 @@ impl LimitClause {
204
206
pub fn parse ( i : & str ) -> IResult < & str , LimitClause , VerboseError < & str > > {
205
207
let ( remaining_input, ( _, _, _, limit, opt_offset) ) = tuple ( (
206
208
multispace0,
207
- tag_no_case ( "limit " ) ,
209
+ tag_no_case ( "LIMIT " ) ,
208
210
multispace1,
209
211
unsigned_number,
210
- opt ( offset) ,
212
+ opt ( Self :: offset) ,
211
213
) ) ( i) ?;
212
214
let offset = opt_offset. unwrap_or_else ( || 0 ) ;
213
215
214
216
Ok ( ( remaining_input, LimitClause { limit, offset } ) )
215
217
}
218
+
219
+ fn offset ( i : & str ) -> IResult < & str , u64 , VerboseError < & str > > {
220
+ let ( remaining_input, ( _, _, _, val) ) = tuple ( (
221
+ multispace0,
222
+ tag_no_case ( "OFFSET" ) ,
223
+ multispace1,
224
+ unsigned_number,
225
+ ) ) ( i) ?;
226
+
227
+ Ok ( ( remaining_input, val) )
228
+ }
216
229
}
217
230
218
231
impl fmt:: Display for LimitClause {
@@ -225,26 +238,15 @@ impl fmt::Display for LimitClause {
225
238
}
226
239
}
227
240
228
- fn offset ( i : & str ) -> IResult < & str , u64 , VerboseError < & str > > {
229
- let ( remaining_input, ( _, _, _, val) ) = tuple ( (
230
- multispace0,
231
- tag_no_case ( "OFFSET" ) ,
232
- multispace1,
233
- unsigned_number,
234
- ) ) ( i) ?;
235
-
236
- Ok ( ( remaining_input, val) )
237
- }
238
-
239
241
#[ cfg( test) ]
240
242
mod tests {
241
243
use base:: { FieldValueExpression , ItemPlaceholder , Operator } ;
242
244
use base:: column:: { Column , FunctionArgument , FunctionArguments , FunctionExpression } ;
243
245
use base:: Literal ;
244
246
use base:: table:: Table ;
245
247
use common:: { JoinConstraint , JoinOperator , JoinRightSide , OrderClause , OrderType } ;
246
- use common:: case:: { CaseWhenExpression , ColumnOrLiteral } ;
247
248
use common:: arithmetic:: { ArithmeticBase , ArithmeticExpression , ArithmeticOperator } ;
249
+ use common:: case:: { CaseWhenExpression , ColumnOrLiteral } ;
248
250
use common:: condition:: { ConditionExpression , ConditionTree } ;
249
251
use common:: condition:: ConditionBase ;
250
252
use common:: condition:: ConditionBase :: LiteralList ;
0 commit comments