parse timezone parameter in mysql connection url (#3418)
* feat(mysql): support configuring the timezone via url * test: add test case for mysql with timezone --------- Co-authored-by: lo <lo@los-MacBook-Pro.local>
This commit is contained in:
parent
4f10962743
commit
94607b5a10
1 changed files with 17 additions and 0 deletions
|
@ -72,6 +72,10 @@ impl MySqlConnectOptions {
|
|||
options = options.socket(&*value);
|
||||
}
|
||||
|
||||
"timezone" | "time-zone" => {
|
||||
options = options.timezone(Some(value.to_string()));
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -176,3 +180,16 @@ fn it_returns_the_parsed_url() {
|
|||
|
||||
assert_eq!(expected_url, opts.build_url());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_parses_timezone() {
|
||||
let opts: MySqlConnectOptions = "mysql://user:password@hostname/database?timezone=%2B08:00"
|
||||
.parse()
|
||||
.unwrap();
|
||||
assert_eq!(opts.timezone.as_deref(), Some("+08:00"));
|
||||
|
||||
let opts: MySqlConnectOptions = "mysql://user:password@hostname/database?time-zone=%2B08:00"
|
||||
.parse()
|
||||
.unwrap();
|
||||
assert_eq!(opts.timezone.as_deref(), Some("+08:00"));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue