Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 authored and tyt2y3 committed Jun 8, 2023
1 parent 5a30a58 commit bb6bee7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/mysql/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ impl SchemaDiscovery {
}

pub async fn discover(mut self) -> Result<Schema, SqlxError> {
let system_info = self
.discover_system()
.await
.and_then(|system_info_opt| system_info_opt.ok_or(SqlxError::RowNotFound))?;
self.query = SchemaQueryBuilder::new(system_info);
self.query = SchemaQueryBuilder::new(self.discover_system().await?);
let tables = self.discover_tables().await?;
let tables = future::try_join_all(
tables
Expand All @@ -54,7 +50,7 @@ impl SchemaDiscovery {
})
}

pub async fn discover_system(&mut self) -> Result<Option<SystemInfo>, SqlxError> {
pub async fn discover_system(&mut self) -> Result<SystemInfo, SqlxError> {
let rows = self.executor.fetch_all(self.query.query_version()).await?;

#[allow(clippy::never_loop)]
Expand All @@ -63,9 +59,9 @@ impl SchemaDiscovery {
debug_print!("{:?}", result);
let version = result.parse();
debug_print!("{:?}", version);
return Ok(Some(version));
return Ok(version);
}
Ok(None)
Err(SqlxError::RowNotFound)
}

pub async fn discover_tables(&mut self) -> Result<Vec<TableInfo>, SqlxError> {
Expand Down

0 comments on commit bb6bee7

Please sign in to comment.