MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / parse_insert

Method parse_insert

nodedb-sql/src/parser/array_stmt/parse_impl.rs:319–357  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

317 // ── INSERT INTO ARRAY ────────────────────────────────────────
318
319 pub(super) fn parse_insert(&mut self) -> Result<InsertArrayAst> {
320 let name = self.expect_ident()?;
321 let mut rows = Vec::new();
322 loop {
323 self.expect_kw("COORDS")?;
324 self.expect(&Tok::LParen)?;
325 let mut coords = Vec::new();
326 loop {
327 coords.push(self.parse_coord_literal()?);
328 if !self.match_token(&Tok::Comma) {
329 break;
330 }
331 }
332 self.expect(&Tok::RParen)?;
333
334 self.expect_kw("VALUES")?;
335 self.expect(&Tok::LParen)?;
336 let mut attrs = Vec::new();
337 loop {
338 attrs.push(self.parse_attr_literal()?);
339 if !self.match_token(&Tok::Comma) {
340 break;
341 }
342 }
343 self.expect(&Tok::RParen)?;
344
345 rows.push(ArrayInsertRow { coords, attrs });
346 if !self.match_token(&Tok::Comma) {
347 break;
348 }
349 }
350 if !self.at_end() {
351 return Err(self.err(format!(
352 "trailing tokens after INSERT INTO ARRAY: {:?}",
353 self.peek()
354 )));
355 }
356 Ok(InsertArrayAst { name, rows })
357 }
358
359 fn parse_coord_literal(&mut self) -> Result<ArrayCoordLiteral> {
360 match self.bump().map(|t| &t.tok) {

Callers 1

Calls 9

expect_identMethod · 0.80
expect_kwMethod · 0.80
parse_coord_literalMethod · 0.80
match_tokenMethod · 0.80
parse_attr_literalMethod · 0.80
at_endMethod · 0.80
expectMethod · 0.45
pushMethod · 0.45
errMethod · 0.45

Tested by

no test coverage detected