MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / insert_unresolved_refs

Method insert_unresolved_refs

src/db/unresolved.rs:36–74  ·  view source on GitHub ↗

Inserts a batch of unresolved references using a prepared statement.

(&self, refs: &[UnresolvedRef])

Source from the content-addressed store, hash-verified

34
35 /// Inserts a batch of unresolved references using a prepared statement.
36 pub async fn insert_unresolved_refs(&self, refs: &[UnresolvedRef]) -> Result<()> {
37 if refs.is_empty() {
38 return Ok(());
39 }
40
41 self.with_batch_transaction("insert_unresolved_refs", async {
42 let stmt = self.conn()
43 .prepare("INSERT INTO unresolved_refs (from_node_id,reference_name,reference_kind,line,col,file_path) VALUES (?1,?2,?3,?4,?5,?6)")
44 .await
45 .map_err(|e| TraceDecayError::Database {
46 message: format!("failed to prepare: {e}"),
47 operation: "insert_unresolved_refs".to_string(),
48 })?;
49
50 for uref in refs {
51 if let Err(e) = stmt
52 .execute(params![
53 uref.from_node_id.as_str(),
54 uref.reference_name.as_str(),
55 uref.reference_kind.as_str(),
56 i64::from(uref.line),
57 i64::from(uref.column),
58 uref.file_path.as_str(),
59 ])
60 .await
61 {
62 stmt.reset();
63 return Err(TraceDecayError::Database {
64 message: format!("failed to insert unresolved ref: {e}"),
65 operation: "insert_unresolved_refs".to_string(),
66 });
67 }
68 stmt.reset();
69 }
70
71 Ok(())
72 })
73 .await
74 }
75
76 /// Returns all unresolved references.
77 pub async fn get_unresolved_refs(&self) -> Result<Vec<UnresolvedRef>> {

Calls 3

is_emptyMethod · 0.45
connMethod · 0.45