fix: Split database name from rules at the last possible function
When updating database rules, the database name should come from the rules. Enforce this by only taking the rules as a parameter, rather than having two arguments that could possibly disagree with each other.pull/24376/head
parent
ddd207bccd
commit
c02e476175
|
@ -157,10 +157,9 @@ where
|
|||
description: e.to_string(),
|
||||
})?;
|
||||
|
||||
let db_name = provided_rules.db_name().clone();
|
||||
let updated_rules = self
|
||||
.server
|
||||
.update_db_rules(&db_name, provided_rules)
|
||||
.update_db_rules(provided_rules)
|
||||
.await
|
||||
.map_err(default_server_error_handler)?;
|
||||
|
||||
|
|
|
@ -1008,10 +1008,10 @@ where
|
|||
/// Update database rules and save on success.
|
||||
pub async fn update_db_rules(
|
||||
&self,
|
||||
db_name: &DatabaseName<'_>,
|
||||
rules: ProvidedDatabaseRules,
|
||||
) -> Result<Arc<ProvidedDatabaseRules>> {
|
||||
let database = self.database(db_name)?;
|
||||
let db_name = rules.db_name().clone();
|
||||
let database = self.database(&db_name)?;
|
||||
|
||||
// attempt to save provided rules in the current state
|
||||
Ok(database
|
||||
|
@ -2417,10 +2417,7 @@ mod tests {
|
|||
};
|
||||
let provided_rules = make_provided_rules(rules);
|
||||
|
||||
server
|
||||
.update_db_rules(&db_name, provided_rules)
|
||||
.await
|
||||
.unwrap();
|
||||
server.update_db_rules(provided_rules).await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
Loading…
Reference in New Issue