Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get time from sqlx-sqlite directly #412

Merged
merged 9 commits into from
Oct 12, 2022
Merged

Conversation

kyoto7250
Copy link
Contributor

@kyoto7250 kyoto7250 commented Aug 10, 2022

PR Info

Changes

  • get time from sqlx-sqlite directly

Breaking Changes

  • In DateType, time is no longer compatible with chrono .

@kyoto7250 kyoto7250 marked this pull request as ready for review August 10, 2022 12:34
v @ Value::TimeDate(_) => query.bind(v.time_as_naive_utc_in_string()),
v @ Value::TimeTime(_) => query.bind(v.time_as_naive_utc_in_string()),
v @ Value::TimeDateTime(_) => query.bind(v.time_as_naive_utc_in_string()),
v @ Value::TimeDateTimeWithTimeZone(_) => query.bind(v.time_as_naive_utc_in_string()),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time_as_naive_utc_in_string is still used by rusqlite and cannot be removed.

Copy link
Member

@ikrivosheev ikrivosheev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikrivosheev
Copy link
Member

@kyoto7250 some tests failed

@kyoto7250
Copy link
Contributor Author

kyoto7250 commented Aug 10, 2022

Ah, This code does not work because It is not pattern matching anymore.
I didn't notice because the test passes.

v @ Value::TimeDate(_) => query.bind(v.as_deref())

Thank you, I fixed in a8806ed.

Copy link
Member

@ikrivosheev ikrivosheev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyoto7250 thank you! LGTM!

@kyoto7250
Copy link
Contributor Author

@ikrivosheev

Hmm, we got a runtime error in CI.

Sorry, I will check it.

@ikrivosheev
Copy link
Member

@ikrivosheev

Hmm, we got a runtime error in CI.

Sorry, I will check it.

I think sqlx convert time object differently than sea-query do it before...

@kyoto7250
Copy link
Contributor Author

kyoto7250 commented Aug 14, 2022

It appears that sqlx v0.6.1 returns subsecond in DateTime, but this behaviour is different from chrono.
I think this PR includes breaking change.

sea-query/src/value.rs

Lines 436 to 437 in 6db27fd

pub static FORMAT_DATETIME: &[FormatItem<'static>] =
format_description!("[year]-[month]-[day] [hour]:[minute]:[second]");

Copy link
Member

@billy1624 billy1624 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kyoto7250, thanks for the contributions!

Yes, this PR contains breaking changes, to be specific,

  • Value::TimeDate(Option<Box<time::Date>>) is being serialized and store as String with format
    • old format: [year]-[month]-[day]
    • new format: [year]-[month]-[day]
    • No Change!
  • Value::TimeTime(Option<Box<time::Time>>) is being serialized and store as String with format
    • old format: [hour]:[minute]:[second]
    • new format: [hour]:[minute]:[second].[subsecond]
  • Value::TimeDateTime(Option<Box<PrimitiveDateTime>>) is being serialized and store as String with format
    • old format: [year]-[month]-[day] [hour]:[minute]:[second]
    • new format: [year]-[month]-[day] [hour]:[minute]:[second].[subsecond]
  • Value::TimeDateTimeWithTimeZone(Option<Box<OffsetDateTime>>) is being serialized and store as String with format
    • old format: [year]-[month]-[day] [hour]:[minute]:[second] [offset_hour sign:mandatory][offset_minute]
    • new format: [year]-[month]-[day]T[hour]:[minute]:[second].[subsecond]Z (RFC 3339)

Copy link
Member

@ikrivosheev ikrivosheev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikrivosheev ikrivosheev self-requested a review August 25, 2022 13:46
src/value.rs Outdated
Comment on lines 435 to 439
format_description!("[hour]:[minute]:[second].[subsecond]");
pub static FORMAT_DATETIME: &[FormatItem<'static>] =
format_description!("[year]-[month]-[day] [hour]:[minute]:[second]");
pub static FORMAT_DATETIME_TZ: &[FormatItem<'static>] = format_description!(
"[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour sign:mandatory][offset_minute]"
);
format_description!("[year]-[month]-[day] [hour]:[minute]:[second].[subsecond]");
pub static FORMAT_DATETIME_TZ: &[FormatItem<'static>] =
format_description!("[year]-[month]-[day] [hour]:[minute]:[second].[subsecond]Z");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kyoto7250, I don't think we need to change this part of the code. This is just for to_string on SQL statement and it has nothing to do with value binding. I think we should keep it as-is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts? @kyoto7250

@kyoto7250
Copy link
Contributor Author

Sorry, I am traveling until this week, so I will check it in this weekend.

Thank you for your kind 👍🏽

@kyoto7250
Copy link
Contributor Author

I'm sorry I'm late.
I resolved the conflict.
And I revert 34b96fb, so could you please review again?

@ikrivosheev
Copy link
Member

@kyoto7250 hello! Can you resolve merge conflict?

@ikrivosheev
Copy link
Member

@kyoto7250 any updates?

Copy link
Member

@ikrivosheev ikrivosheev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyoto7250 thank you! LGTM!

@ikrivosheev ikrivosheev requested a review from billy1624 October 2, 2022 13:37
Copy link
Member

@billy1624 billy1624 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!! @kyoto7250

Copy link
Member

@tyt2y3 tyt2y3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikrivosheev feel free to merge it

@ikrivosheev ikrivosheev merged commit d1ecbda into SeaQL:master Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[SeaQuery] Support time crate on SQLite
4 participants