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

Implement support for more time types #1374

Merged
merged 3 commits into from
Jul 29, 2023
Merged

Implement support for more time types #1374

merged 3 commits into from
Jul 29, 2023

Conversation

nydrani
Copy link
Contributor

@nydrani nydrani commented Jul 28, 2023

Opening this PR to revive support for more time types. I've cherry picked the changes from #1282.

Closes #1282
Closes #1281

This PR implements support for the following types:

  • time::Time
  • time::Date
  • time::PrimitiveDateTime

It also adds support for keeping the original OffsetDateTime when serializing via ToSql.

This PR implements support for the following types:
* `time::Time`
* `time::Date`
* `time::PrimitiveDateTime`
@gwenn
Copy link
Collaborator

gwenn commented Jul 28, 2023

format_description!(version = 2, "[hour]:[minute]:[second].[subsecond]");
const DATE_ENCODING: &[FormatItem<'_>] = format_description!(version = 2, "[year]-[month]-[day]");

const DATE_FORMAT: &[FormatItem<'_>] = format_description!(version = 2, "[year]-[month]-[day]");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicates: DATE_ENCODING == DATE_FORMAT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed duplication

nydrani and others added 2 commits July 29, 2023 11:09
Simplify deserializing `time::OffsetDateTime`
Add `YYYY-MM-DD HH:MM` support for `time::OffsetDateTime` and
`time::PrimitiveDateTime`
@nydrani
Copy link
Contributor Author

nydrani commented Jul 29, 2023

  1. Implement support for more time types #1282 is still open

    1. Do the comments in Implement support for more time types #1282 are fixed in Implement support for more time types #1374 ?
  1. I opened this PR because Implement support for more time types #1282 has no activity for a while.
  2. Yes all comments from Implement support for more time types #1282 have been addressed here.

@codecov
Copy link

codecov bot commented Jul 29, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.33% 🎉

Comparison is base (a0f5b4c) 80.96% compared to head (55fd19e) 81.30%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1374      +/-   ##
==========================================
+ Coverage   80.96%   81.30%   +0.33%     
==========================================
  Files          49       49              
  Lines       10050    10227     +177     
==========================================
+ Hits         8137     8315     +178     
+ Misses       1913     1912       -1     
Files Changed Coverage Δ
src/types/time.rs 100.00% <100.00%> (+0.90%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gwenn gwenn merged commit e093d7d into rusqlite:master Jul 29, 2023
16 checks passed
@gwenn
Copy link
Collaborator

gwenn commented Jul 29, 2023

Thanks

@nydrani nydrani deleted the time-support branch July 29, 2023 06:47
bors added a commit to rust-lang/cargo that referenced this pull request Dec 1, 2023
chore(deps): update rust crate rusqlite to 0.30.0

[![Mend Renovate logo banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rusqlite](https://togithub.com/rusqlite/rusqlite) | workspace.dependencies | minor | `0.29.0` -> `0.30.0` |

---

### Release Notes

<details>
<summary>rusqlite/rusqlite (rusqlite)</summary>

### [`v0.30.0`](https://togithub.com/rusqlite/rusqlite/releases/tag/v0.30.0): 0.30.0

[Compare Source](https://togithub.com/rusqlite/rusqlite/compare/v0.29.0...v0.30.0)

#### What's Changed

-   Fix sqlite3\_auto_extension xEntryPoint signature [#&#8203;1310](https://togithub.com/rusqlite/rusqlite/issues/1310)
-   Use track_caller for panicking methods [#&#8203;1314](https://togithub.com/rusqlite/rusqlite/issues/1314)
-   Force linking against system sqlite libs [#&#8203;1317](https://togithub.com/rusqlite/rusqlite/issues/1317)
-   fix compilation for target wasm32-wasi [#&#8203;1321](https://togithub.com/rusqlite/rusqlite/issues/1321)
-   Add SQLITE_MAX_COLUMN compile-time option [#&#8203;1324](https://togithub.com/rusqlite/rusqlite/issues/1324)
-   Upgrade http links to https in Cargo.toml [#&#8203;1330](https://togithub.com/rusqlite/rusqlite/issues/1330)
-   Update fallible-iterator requirement from 0.2 to 0.3 [#&#8203;1334](https://togithub.com/rusqlite/rusqlite/issues/1334)
-   Implement FromSql & ToSql for std::num::NonZero types [#&#8203;1313](https://togithub.com/rusqlite/rusqlite/issues/1313)
-   Add new constants introduced by SQLite 3.42.0 [#&#8203;1336](https://togithub.com/rusqlite/rusqlite/issues/1336)
-   Use SQLITE_PREPARE_PERSISTENT for CachedStatement [#&#8203;1339](https://togithub.com/rusqlite/rusqlite/issues/1339)
-   Fix type of SQLITE_DESERIALIZE\_*, SQLITE_PREPARE\_*, SQLITE_SERIALIZE_\* [#&#8203;1340](https://togithub.com/rusqlite/rusqlite/issues/1340)
-   Introduce to_sqlite_error [#&#8203;1345](https://togithub.com/rusqlite/rusqlite/issues/1345)
-   remove depth from Savepoint [#&#8203;1327](https://togithub.com/rusqlite/rusqlite/issues/1327)
-   Savepoint Drop bug [#&#8203;1347](https://togithub.com/rusqlite/rusqlite/issues/1347)
-   \[breaking change] Update edition from 2018 to 2021 [#&#8203;1267](https://togithub.com/rusqlite/rusqlite/issues/1267)
-   Remove msrv for clippy by [#&#8203;1351](https://togithub.com/rusqlite/rusqlite/issues/1351)
-   Tweak bindgen [#&#8203;1352](https://togithub.com/rusqlite/rusqlite/issues/1352), [#&#8203;1353](https://togithub.com/rusqlite/rusqlite/issues/1353)
-   Inline constraint_error_code [#&#8203;1359](https://togithub.com/rusqlite/rusqlite/issues/1359)
-   Simplify bindgen generation [#&#8203;1360](https://togithub.com/rusqlite/rusqlite/issues/1360)
-   Fixes generate_series to handle NULL arguments [#&#8203;1357](https://togithub.com/rusqlite/rusqlite/issues/1357)
-   Factorize code in build.rs [#&#8203;1361](https://togithub.com/rusqlite/rusqlite/issues/1361)
-   Serialize and deserialize database [#&#8203;1341](https://togithub.com/rusqlite/rusqlite/issues/1341)
-   Spelling and a few more nits [#&#8203;1373](https://togithub.com/rusqlite/rusqlite/issues/1373)
-   Implement support for more `time` types [#&#8203;1374](https://togithub.com/rusqlite/rusqlite/issues/1374)
-   Fix visibility of TransactionState [#&#8203;1384](https://togithub.com/rusqlite/rusqlite/issues/1384)
-   Column is used only with column_decltype feature [#&#8203;1385](https://togithub.com/rusqlite/rusqlite/issues/1385)
-   Use proper var names in trait definition [#&#8203;1398](https://togithub.com/rusqlite/rusqlite/issues/1398)
-   Fix clippy warning: arc_with_non_send_sync - interrupt_lock [#&#8203;1400](https://togithub.com/rusqlite/rusqlite/issues/1400)
-   Captured identifiers in SQL strings [#&#8203;1346](https://togithub.com/rusqlite/rusqlite/issues/1346)
-   Add new constants introduced by SQLite 3.43.0 [#&#8203;1405](https://togithub.com/rusqlite/rusqlite/issues/1405)
-   Make WindowAggregate::value pass mutable value ref [#&#8203;1395](https://togithub.com/rusqlite/rusqlite/issues/1395)
-   Bump bundled SQLite version to 3.44.0 [#&#8203;1409](https://togithub.com/rusqlite/rusqlite/issues/1409)
-   Bump bindgen version to 0.69 [#&#8203;1410](https://togithub.com/rusqlite/rusqlite/issues/1410)
-   Loadable extension [#&#8203;1362](https://togithub.com/rusqlite/rusqlite/issues/1362)

#### New Contributors

-   [`@&#8203;icp1994](https://togithub.com/icp1994)` made their first contribution in [rusqlite/rusqlite#1317
-   [`@&#8203;wasm-forge](https://togithub.com/wasm-forge)` made their first contribution in [rusqlite/rusqlite#1321
-   [`@&#8203;nopjia](https://togithub.com/nopjia)` made their first contribution in [rusqlite/rusqlite#1324
-   [`@&#8203;Benjins-automation](https://togithub.com/Benjins-automation)` made their first contribution in [rusqlite/rusqlite#1330
-   [`@&#8203;itsxaos](https://togithub.com/itsxaos)` made their first contribution in [rusqlite/rusqlite#1313
-   [`@&#8203;Taywee](https://togithub.com/Taywee)` made their first contribution in [rusqlite/rusqlite#1327
-   [`@&#8203;davidselassie](https://togithub.com/davidselassie)` made their first contribution in [rusqlite/rusqlite#1357
-   [`@&#8203;nyurik](https://togithub.com/nyurik)` made their first contribution in [rusqlite/rusqlite#1373
-   [`@&#8203;nydrani](https://togithub.com/nydrani)` made their first contribution in [rusqlite/rusqlite#1374

**Full Changelog**: rusqlite/rusqlite@v0.29.0...v0.30.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 5am on the first day of the month" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/rust-lang/cargo).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support more types from the time crate
3 participants