Skip to content

Commit

Permalink
fix: revert some of the box stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking committed Apr 29, 2024
1 parent 2d0ea9a commit 085e3a1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 deletions.
7 changes: 4 additions & 3 deletions rust/core/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ async fn render_model_select_statement(
})?;
let replaced = reference_search.replace_all(
sql.as_str(),
replace_reference_string_found(&HashMap::new(), &database),
replace_reference_string_found(&HashMap::new(), database),
);
let connection_config = project
.connection_config
Expand Down Expand Up @@ -1593,7 +1593,7 @@ async fn render_snapshot_select_statement(
})?;
let replaced = reference_search.replace_all(
sql.as_str(),
replace_reference_string_found(&HashMap::new(), &database),
replace_reference_string_found(&HashMap::new(), database),
);
let connection_config = project
.connection_config
Expand Down Expand Up @@ -1676,8 +1676,9 @@ fn replace_reference_string_found_with_database<'a>(

pub fn replace_reference_string_found<'a>(
overrides: &'a HashMap<String, String>,
database: &'a &impl DatabaseQueryGenerator,
database: &'a (impl DatabaseQueryGenerator + ?Sized),
) -> Box<dyn Fn(&regex::Captures) -> String + 'a> {
let database = database.clone();
#[allow(clippy::indexing_slicing)]
Box::new(move |caps: &regex::Captures| {
let model = &caps[1];
Expand Down
4 changes: 2 additions & 2 deletions rust/core/src/project_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub async fn return_tests_sql(
.map_err(|e| format!("failed to return reference search: {}", e))?;
let sql = reference_search.clone().replace_all(
file.as_str(),
replace_reference_string_found(&sources, &database),
replace_reference_string_found(&sources, database),
);
Ok(sql.to_string())
}
Expand Down Expand Up @@ -243,7 +243,7 @@ pub async fn return_tests_sql(
.map_err(|e| format!("failed to return reference search: {}", e))?;
let sql = reference_search.replace_all(
&file,
replace_reference_string_found(&path_map, &database),
replace_reference_string_found(&path_map, database),
);
Ok((name, sql.to_string()))
}
Expand Down
24 changes: 16 additions & 8 deletions rust/quary-databases/src/databases_duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,10 +956,14 @@ snapshots:
.await
.unwrap();

let snapshots_sql =
project_and_fs_to_sql_for_snapshots(&project, &file_system, &db_generator, database.as_ref())
.await
.unwrap();
let snapshots_sql = project_and_fs_to_sql_for_snapshots(
&project,
&file_system,
&db_generator,
database.as_ref(),
)
.await
.unwrap();
for (_, sql) in snapshots_sql {
for statement in sql {
database.exec(statement.as_str()).await.unwrap()
Expand Down Expand Up @@ -1184,10 +1188,14 @@ snapshots:
.await
.unwrap();

let snapshots_sql =
project_and_fs_to_sql_for_snapshots(&project, &file_system, &db_generator, database.as_ref())
.await
.unwrap();
let snapshots_sql = project_and_fs_to_sql_for_snapshots(
&project,
&file_system,
&db_generator,
database.as_ref(),
)
.await
.unwrap();
for (_, sql) in snapshots_sql {
for statement in sql {
database.exec(statement.as_str()).await.unwrap()
Expand Down
12 changes: 8 additions & 4 deletions rust/quary-databases/src/databases_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,10 +1211,14 @@ snapshots:
.await
.unwrap();

let snapshots_sql =
project_and_fs_to_sql_for_snapshots(&project, &file_system, &db_generator, database.as_ref())
.await
.unwrap();
let snapshots_sql = project_and_fs_to_sql_for_snapshots(
&project,
&file_system,
&db_generator,
database.as_ref(),
)
.await
.unwrap();
for (_, sql) in snapshots_sql {
for statement in sql {
database.exec(statement.as_str()).await.unwrap()
Expand Down
12 changes: 8 additions & 4 deletions rust/quary-databases/src/databases_redshift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,14 @@ mod tests {
.await
.unwrap();

let snapshots_sql =
project_and_fs_to_sql_for_snapshots(&project, &file_system, &db_generator, database.as_ref())
.await
.unwrap();
let snapshots_sql = project_and_fs_to_sql_for_snapshots(
&project,
&file_system,
&db_generator,
database.as_ref(),
)
.await
.unwrap();
for (_, sql) in snapshots_sql {
for statement in sql {
println!("{}", statement.as_str());
Expand Down

0 comments on commit 085e3a1

Please sign in to comment.