MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_update

Method parse_update

src/sql-parser/src/parser.rs:8623–8647  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

8621 }
8622
8623 fn parse_update(&mut self) -> Result<Statement<Raw>, ParserError> {
8624 let table_name = RawItemName::Name(self.parse_item_name()?);
8625 // The alias here doesn't support columns, so don't use parse_optional_table_alias.
8626 let alias = self.parse_optional_alias(Keyword::is_reserved_in_table_alias)?;
8627 let alias = alias.map(|name| TableAlias {
8628 name,
8629 columns: Vec::new(),
8630 strict: false,
8631 });
8632
8633 self.expect_keyword(SET)?;
8634 let assignments = self.parse_comma_separated(Parser::parse_assignment)?;
8635 let selection = if self.parse_keyword(WHERE) {
8636 Some(self.parse_expr()?)
8637 } else {
8638 None
8639 };
8640
8641 Ok(Statement::Update(UpdateStatement {
8642 table_name,
8643 alias,
8644 assignments,
8645 selection,
8646 }))
8647 }
8648
8649 /// Parse a `var = expr` assignment, used in an UPDATE statement
8650 fn parse_assignment(&mut self) -> Result<Assignment<Raw>, ParserError> {

Callers 1

parse_statement_innerMethod · 0.45

Calls 9

parse_item_nameMethod · 0.80
parse_optional_aliasMethod · 0.80
expect_keywordMethod · 0.80
parse_comma_separatedMethod · 0.80
parse_keywordMethod · 0.80
parse_exprMethod · 0.80
NameClass · 0.50
UpdateClass · 0.50
mapMethod · 0.45

Tested by

no test coverage detected