@@ -3447,10 +3447,7 @@ pub enum Statement {
34473447 /// Cursor name
34483448 name : Ident ,
34493449 direction : FetchDirection ,
3450- /// Differentiate between dialects that fetch `FROM` vs fetch `IN`
3451- ///
3452- /// [MsSql](https://learn.microsoft.com/en-us/sql/t-sql/language-elements/fetch-transact-sql)
3453- from_or_in : AttachedToken ,
3450+ position : FetchPosition ,
34543451 /// Optional, It's possible to fetch rows form cursor to the table
34553452 into : Option < ObjectName > ,
34563453 } ,
@@ -4273,25 +4270,10 @@ impl fmt::Display for Statement {
42734270 Statement :: Fetch {
42744271 name,
42754272 direction,
4276- from_or_in ,
4273+ position ,
42774274 into,
42784275 } => {
4279- write ! ( f, "FETCH {direction} " ) ?;
4280-
4281- match & from_or_in. 0 . token {
4282- Token :: Word ( w) => match w. keyword {
4283- Keyword :: FROM => {
4284- write ! ( f, "FROM {name}" ) ?;
4285- }
4286- Keyword :: IN => {
4287- write ! ( f, "IN {name}" ) ?;
4288- }
4289- _ => unreachable ! ( ) ,
4290- } ,
4291- _ => {
4292- unreachable ! ( )
4293- }
4294- }
4276+ write ! ( f, "FETCH {direction} {position} {name}" ) ?;
42954277
42964278 if let Some ( into) = into {
42974279 write ! ( f, " INTO {into}" ) ?;
@@ -6232,6 +6214,28 @@ impl fmt::Display for FetchDirection {
62326214 }
62336215}
62346216
6217+ /// The "position" for a FETCH statement.
6218+ ///
6219+ /// [MsSql](https://learn.microsoft.com/en-us/sql/t-sql/language-elements/fetch-transact-sql)
6220+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6221+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6222+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6223+ pub enum FetchPosition {
6224+ From ,
6225+ In ,
6226+ }
6227+
6228+ impl fmt:: Display for FetchPosition {
6229+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6230+ match self {
6231+ FetchPosition :: From => f. write_str ( "FROM" ) ?,
6232+ FetchPosition :: In => f. write_str ( "IN" ) ?,
6233+ } ;
6234+
6235+ Ok ( ( ) )
6236+ }
6237+ }
6238+
62356239/// A privilege on a database object (table, sequence, etc.).
62366240#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
62376241#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
0 commit comments