Open gabrielkim13 opened 4 months ago
Thanks for filing this! Awesome (irony) that our tests did not find this :cry:
You're welcome! And thanks for the quick response :)
Same bug I believe: https://github.com/mehcode/config-rs/issues/531
rename
should work presumably if only using lowercase value? Looks like 0.14.0
has some fixes contributed that converted to lowercase that broke serde features.
I've encountered the same issue. When using config@0.14 in combination with serde, applying #[serde(rename_all = "camelCase")] to handle the yaml configuration file does not work as expected. Below is the configuration file:
dataBase:
url: "http://www.ss.com.cn"
userName: "张三"
password: "1233"
addr: "0.0.0.0:8887"
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Conf {
pub data_base: Option<DataBase>,
pub addr: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DataBase {
pub url: String,
pub user_name: String,
pub password: String,
#[serde(default)]
pub data_base_connection_poll: DataBaseConnectionPool,
}
When I reverted the config to version 0.13, this code executed as expected.
Starting at
config@0.14.0
,serde
renamed fields are no longer supported due to the "missing field" error.Consider the following minimal reproduceable example:
The output is as follows:
Reverting the dependency back to
config@0.13.4
works as expected: