@@ -535,7 +535,7 @@ impl fmt::Display for ExceptSelectItem {
535
535
///
536
536
/// # Syntax
537
537
/// ```plaintext
538
- /// REPLACE <new_expr> AS <col_name>
538
+ /// REPLACE <new_expr> [AS] <col_name>
539
539
/// ```
540
540
#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
541
541
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
@@ -545,15 +545,15 @@ pub enum ReplaceSelectItem {
545
545
///
546
546
/// # Syntax
547
547
/// ```plaintext
548
- /// <col_name> AS <col_alias>
548
+ /// <col_name> [AS] <col_alias>
549
549
/// ```
550
- Single ( Box < SelectItem > ) ,
550
+ Single ( Box < ReplaceSelectElement > ) ,
551
551
/// Multiple column names with aliases inside parenthesis.
552
552
/// # Syntax
553
553
/// ```plaintext
554
- /// (<col_name> AS <col_alias>, <col_name> AS <col_alias>, ...)
554
+ /// (<col_name> [AS] <col_alias>, <col_name> [AS] <col_alias>, ...)
555
555
/// ```
556
- Multiple ( Vec < Box < SelectItem > > ) ,
556
+ Multiple ( Vec < Box < ReplaceSelectElement > > ) ,
557
557
}
558
558
559
559
impl fmt:: Display for ReplaceSelectItem {
@@ -571,6 +571,27 @@ impl fmt::Display for ReplaceSelectItem {
571
571
}
572
572
}
573
573
574
+ /// # Syntax
575
+ /// ```plaintext
576
+ /// <expr> [AS] <column_name>
577
+ /// ```
578
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
579
+ pub struct ReplaceSelectElement {
580
+ pub expr : Expr ,
581
+ pub colum_name : Ident ,
582
+ pub as_keyword : bool ,
583
+ }
584
+
585
+ impl fmt:: Display for ReplaceSelectElement {
586
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
587
+ if self . as_keyword {
588
+ write ! ( f, "{} AS {}" , self . expr, self . colum_name)
589
+ } else {
590
+ write ! ( f, "{} {}" , self . expr, self . colum_name)
591
+ }
592
+ }
593
+ }
594
+
574
595
impl fmt:: Display for SelectItem {
575
596
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
576
597
match & self {
0 commit comments