MCPcopy Create free account
hub / github.com/douglance/devsql / load_table

Method load_table

crates/vcsql/src/sql/engine.rs:88–123  ·  view source on GitHub ↗

Loads a single table's data from the repository into the database. Tables are cached after first load - subsequent calls for the same table are no-ops.

(&mut self, table_name: &str, repo: &mut GitRepo)

Source from the content-addressed store, hash-verified

86 ///
87 /// Tables are cached after first load - subsequent calls for the same table are no-ops.
88 pub fn load_table(&mut self, table_name: &str, repo: &mut GitRepo) -> Result<()> {
89 if self.loaded_tables.contains(table_name) {
90 return Ok(());
91 }
92
93 let table_info = get_table_info(table_name)
94 .ok_or_else(|| VcsqlError::TableNotFound(table_name.to_string()))?;
95
96 self.conn.execute(table_info.create_sql, [])?;
97
98 let provider: Box<dyn Provider> = match table_name {
99 "commits" => Box::new(CommitsProvider),
100 "commit_parents" => Box::new(CommitParentsProvider),
101 "branches" => Box::new(BranchesProvider),
102 "tags" => Box::new(TagsProvider),
103 "refs" => Box::new(RefsProvider),
104 "stashes" => Box::new(StashesProvider),
105 "reflog" => Box::new(ReflogProvider),
106 "diffs" => Box::new(DiffsProvider),
107 "diff_files" => Box::new(DiffFilesProvider),
108 "blame" => Box::new(BlameProvider::new(None)),
109 "config" => Box::new(ConfigProvider),
110 "remotes" => Box::new(RemotesProvider),
111 "submodules" => Box::new(SubmodulesProvider),
112 "status" => Box::new(StatusProvider),
113 "worktrees" => Box::new(WorktreesProvider),
114 "hooks" => Box::new(HooksProvider),
115 "notes" => Box::new(NotesProvider),
116 _ => return Err(VcsqlError::TableNotFound(table_name.to_string())),
117 };
118
119 provider.populate(&self.conn, repo)?;
120 self.loaded_tables.insert(table_name.to_string());
121
122 Ok(())
123 }
124
125 /// Loads all tables referenced in a query from the repository.
126 ///

Callers 2

load_tables_for_queryMethod · 0.80
test_table_not_foundFunction · 0.80

Calls 3

get_table_infoFunction · 0.85
executeMethod · 0.45
populateMethod · 0.45

Tested by 1

test_table_not_foundFunction · 0.64