diff --git a/CHANGELOG.md b/CHANGELOG.md index 216443be..fd0c4faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ This changelog documents the changes between release versions. ## [Unreleased] - Fix incorrect order of results for query requests with more than 10 variable sets (#37) +- In the CLI update command, don't overwrite schema files that haven't changed ([#49](https://github.com/hasura/ndc-mongodb/pull/49/files)) ## [0.0.4] - 2024-04-12 - Queries that attempt to compare a column to a column in the query root table, or a related table, will now fail instead of giving the incorrect result ([#22](https://github.com/hasura/ndc-mongodb/pull/22)) diff --git a/crates/configuration/src/directory.rs b/crates/configuration/src/directory.rs index aa1b9871..1e659561 100644 --- a/crates/configuration/src/directory.rs +++ b/crates/configuration/src/directory.rs @@ -164,7 +164,14 @@ where { let path = default_file_path(configuration_dir, basename); let bytes = serde_json::to_vec_pretty(value)?; - fs::write(path.clone(), bytes) + + // Don't write the file if it hasn't changed. + if let Ok(existing_bytes) = fs::read(&path).await { + if bytes == existing_bytes { + return Ok(()) + } + } + fs::write(&path, bytes) .await .with_context(|| format!("error writing {:?}", path)) }