@@ -4553,13 +4553,35 @@ impl fmt::Display for GrantObjects {
45534553#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
45544554#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
45554555pub struct Assignment {
4556- pub id : Vec < Ident > ,
4556+ pub target : AssignmentTarget ,
45574557 pub value : Expr ,
45584558}
45594559
45604560impl fmt:: Display for Assignment {
45614561 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4562- write ! ( f, "{} = {}" , display_separated( & self . id, "." ) , self . value)
4562+ write ! ( f, "{} = {}" , self . target, self . value)
4563+ }
4564+ }
4565+
4566+ /// Left-hand side of an assignment in an UPDATE statement,
4567+ /// e.g. `foo` in `foo = 5` (ColumnName assignment) or
4568+ /// `(a, b)` in `(a, b) = (1, 2)` (Tuple assignment).
4569+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4570+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4571+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4572+ pub enum AssignmentTarget {
4573+ /// A single column
4574+ ColumnName ( ObjectName ) ,
4575+ /// A tuple of columns
4576+ Tuple ( Vec < ObjectName > ) ,
4577+ }
4578+
4579+ impl fmt:: Display for AssignmentTarget {
4580+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4581+ match self {
4582+ AssignmentTarget :: ColumnName ( column) => write ! ( f, "{}" , column) ,
4583+ AssignmentTarget :: Tuple ( columns) => write ! ( f, "({})" , display_comma_separated( columns) ) ,
4584+ }
45634585 }
45644586}
45654587
0 commit comments