-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle native types for joined queries (#4546)
- Loading branch information
Showing
15 changed files
with
518 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use chrono::*; | ||
|
||
pub(crate) fn parse_date(str: &str) -> Result<DateTime<FixedOffset>, chrono::ParseError> { | ||
chrono::NaiveDate::parse_from_str(str, "%Y-%m-%d") | ||
.map(|date| DateTime::<Utc>::from_utc(date.and_hms_opt(0, 0, 0).unwrap(), Utc)) | ||
.map(DateTime::<FixedOffset>::from) | ||
} | ||
|
||
pub(crate) fn parse_timestamptz(str: &str) -> Result<DateTime<FixedOffset>, chrono::ParseError> { | ||
DateTime::parse_from_rfc3339(str) | ||
} | ||
|
||
pub(crate) fn parse_timestamp(str: &str) -> Result<DateTime<FixedOffset>, chrono::ParseError> { | ||
NaiveDateTime::parse_from_str(str, "%Y-%m-%dT%H:%M:%S%.f") | ||
.map(|dt| DateTime::from_utc(dt, Utc)) | ||
.or_else(|_| DateTime::parse_from_rfc3339(str).map(DateTime::<Utc>::from)) | ||
.map(DateTime::<FixedOffset>::from) | ||
} | ||
|
||
pub(crate) fn parse_time(str: &str) -> Result<DateTime<FixedOffset>, chrono::ParseError> { | ||
chrono::NaiveTime::parse_from_str(str, "%H:%M:%S%.f") | ||
.map(|time| { | ||
let base_date = chrono::NaiveDate::from_ymd_opt(1970, 1, 1).unwrap(); | ||
|
||
DateTime::<Utc>::from_utc(base_date.and_time(time), Utc) | ||
}) | ||
.map(DateTime::<FixedOffset>::from) | ||
} | ||
|
||
pub(crate) fn parse_timetz(str: &str) -> Result<DateTime<FixedOffset>, chrono::ParseError> { | ||
// We currently don't support time with timezone. | ||
// We strip the timezone information and parse it as a time. | ||
// This is inline with what Quaint does already. | ||
let time_without_tz = str.split('+').next().unwrap(); | ||
|
||
parse_time(time_without_tz) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ mod enum_type; | |
mod float; | ||
mod int; | ||
mod json; | ||
mod native; | ||
mod string; | ||
mod through_relation; |
1 change: 1 addition & 0 deletions
1
query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/native/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod postgres; |
Oops, something went wrong.