@@ -2,14 +2,15 @@ use nom::branch::alt;
22use nom:: character:: complete:: { alphanumeric1, digit1, line_ending, multispace0, multispace1} ;
33use nom:: character:: is_alphanumeric;
44use nom:: combinator:: { map, not, peek} ;
5- use nom:: { IResult , InputLength , Parser , Err } ;
5+ use nom:: { Err , IResult , InputLength , Parser } ;
66use std:: fmt:: { self , Display } ;
77use std:: str;
88use std:: str:: FromStr ;
99
1010use arithmetic:: { arithmetic_expression, ArithmeticExpression } ;
1111use case:: case_when_column;
1212use column:: { Column , FunctionArgument , FunctionArguments , FunctionExpression } ;
13+ use insert:: InsertDataValue ;
1314use keywords:: { escape_if_keyword, sql_keyword} ;
1415use nom:: bytes:: complete:: { is_not, tag, tag_no_case, take, take_until, take_while1} ;
1516use nom:: combinator:: opt;
@@ -812,7 +813,10 @@ pub fn sql_identifier(i: &[u8]) -> IResult<&[u8], &[u8]> {
812813 ) ) ( i) ?;
813814
814815 if str:: from_utf8 ( si) . unwrap_or ( "0" ) . parse :: < usize > ( ) . is_ok ( ) {
815- return Err ( Err :: Error ( Error { input : i, code : ErrorKind :: IsA } ) ) ;
816+ return Err ( Err :: Error ( Error {
817+ input : i,
818+ code : ErrorKind :: IsA ,
819+ } ) ) ;
816820 }
817821
818822 Ok ( ( i, si) )
@@ -879,7 +883,8 @@ fn field_value_expr(i: &[u8]) -> IResult<&[u8], FieldAssignmentValue> {
879883 FieldValueExpression :: Literal ( LiteralExpression {
880884 value : l. into ( ) ,
881885 alias : None ,
882- } ) . into ( )
886+ } )
887+ . into ( )
883888 } ) ,
884889 ) ) ( i)
885890}
@@ -1066,6 +1071,28 @@ pub fn value_list(i: &[u8]) -> IResult<&[u8], Vec<Literal>> {
10661071 many0 ( delimited ( multispace0, literal, opt ( ws_sep_comma) ) ) ( i)
10671072}
10681073
1074+ pub fn insert_data_value_list ( i : & [ u8 ] ) -> IResult < & [ u8 ] , Vec < InsertDataValue > > {
1075+ many0 ( delimited ( multispace0, insert_data_value, opt ( ws_sep_comma) ) ) ( i)
1076+ }
1077+
1078+ pub fn insert_data_value ( i : & [ u8 ] ) -> IResult < & [ u8 ] , InsertDataValue > {
1079+ alt ( (
1080+ map (
1081+ tuple ( (
1082+ tag_no_case ( "DEFAULT" ) ,
1083+ tag ( "(" ) ,
1084+ multispace0,
1085+ column_identifier_no_alias,
1086+ multispace0,
1087+ tag ( ")" ) ,
1088+ ) ) ,
1089+ |( _, _, _, c, _, _) | InsertDataValue :: ColumnDefault ( c) ,
1090+ ) ,
1091+ map ( tag_no_case ( "DEFAULT" ) , |_| InsertDataValue :: Default ) ,
1092+ map ( literal, |l| InsertDataValue :: Literal ( l) ) ,
1093+ ) ) ( i)
1094+ }
1095+
10691096// Parse a reference to a named schema.table, with an optional alias
10701097pub fn schema_table_reference ( i : & [ u8 ] ) -> IResult < & [ u8 ] , Table > {
10711098 map (
0 commit comments