@@ -3447,10 +3447,7 @@ pub enum Statement {
3447
3447
/// Cursor name
3448
3448
name : Ident ,
3449
3449
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 ,
3454
3451
/// Optional, It's possible to fetch rows form cursor to the table
3455
3452
into : Option < ObjectName > ,
3456
3453
} ,
@@ -4273,25 +4270,10 @@ impl fmt::Display for Statement {
4273
4270
Statement :: Fetch {
4274
4271
name,
4275
4272
direction,
4276
- from_or_in ,
4273
+ position ,
4277
4274
into,
4278
4275
} => {
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}" ) ?;
4295
4277
4296
4278
if let Some ( into) = into {
4297
4279
write ! ( f, " INTO {into}" ) ?;
@@ -6232,6 +6214,28 @@ impl fmt::Display for FetchDirection {
6232
6214
}
6233
6215
}
6234
6216
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
+
6235
6239
/// A privilege on a database object (table, sequence, etc.).
6236
6240
#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6237
6241
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
0 commit comments