Skip to content

Commit

Permalink
Allow not having a target for on conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
antialize committed Feb 17, 2023
1 parent 8033bda commit 5c0d160
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/insert_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,18 @@ pub enum OnConflictTarget<'a> {
on_constraint_span: Span,
name: Identifier<'a>,
},
None,
}

impl<'a> Spanned for OnConflictTarget<'a> {
fn span(&self) -> Span {
impl<'a> OptSpanned for OnConflictTarget<'a> {
fn opt_span(&self) -> Option<Span> {
match self {
OnConflictTarget::Column { name } => name.span(),
OnConflictTarget::Column { name } => Some(name.span()),
OnConflictTarget::OnConstraint {
on_constraint_span: token,
name,
} => token.join_span(name),
} => Some(token.join_span(name)),
OnConflictTarget::None => None,
}
}
}
Expand Down Expand Up @@ -395,7 +397,7 @@ pub(crate) fn parse_insert_replace<'a, 'b>(
name,
}
}
_ => parser.expected_failure("( or ON")?,
_ => OnConflictTarget::None,
};

let do_ = parser.consume_keyword(Keyword::DO)?;
Expand Down

0 comments on commit 5c0d160

Please sign in to comment.