Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions crates/dkdc-db-core/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,17 @@ impl DbManager {
pub async fn execute(&self, db_name: &str, sql: &str) -> Result<u64> {
error::validate_sql(sql)?;
self.ensure_db(db_name).await?;
let dbs = self.dbs.read().await;
let managed = dbs.get(db_name).ok_or_else(|| db_not_found(db_name))?;
let result = managed.db.execute(sql).await?;
let (result, catalog, is_ddl) = {
let dbs = self.dbs.read().await;
let managed = dbs.get(db_name).ok_or_else(|| db_not_found(db_name))?;
let result = managed.db.execute(sql).await?;
let catalog = managed.catalog.clone();
let is_ddl = router::is_ddl(sql);
(result, catalog, is_ddl)
}; // read lock released here
// Refresh catalog if DDL (selective: only the affected table)
if router::is_ddl(sql) {
managed
.catalog
.schema_provider()
.refresh_for_ddl(sql)
.await?;
if is_ddl {
catalog.schema_provider().refresh_for_ddl(sql).await?;
}
Ok(result)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/dkdc-db-core/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub async fn list_tables(conn: &turso::Connection) -> Result<Vec<String>> {
let mut tables = Vec::new();
while let Some(row) = rows.next().await? {
let name: String = row.get(0)?;
tables.push(name);
tables.push(name.to_lowercase());
}
Ok(tables)
}
Expand Down
Loading