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

Re-export the format_description module #3729

Closed
eyyyyyyy3 opened this issue Feb 7, 2025 · 1 comment
Closed

Re-export the format_description module #3729

eyyyyyyy3 opened this issue Feb 7, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@eyyyyyyy3
Copy link

I have found these related issues/pull requests

Relates to #1851.

Description

It would actually be really useful to have access to the format_description module. I am working with protobuf and it has no native Date format.
I can think of some ways to circumvent this:

  • I could create custom messages which I could then parse for every incoming request
  • Add the time crate separately to the project and then use the format_description module
  • Let the DBMS manage the conversion from string to Date

But to be honest I would like to:

  • Avoid creating custom messages for the Date and Timestamp types as this just increases the API complexity
  • Avoid managing the versions of the time feature of sqlx and the additional time dependency
  • Manage the parsing inside of Rust

In general, I think that it is not that uncommon to add a Date or Timestamp which is only available as a string to the database.

Prefered solution

Re-export the format_description module.

Is this a breaking change? Why or why not?

No, as it does not change any structures, functions, methods or traits but rather extends the time crate with additional (and arguably necessary) parsing functionalities.

@abonander
Copy link
Collaborator

Sorry, but the answer is still no. The sqlx crate is not intended to be a one-stop shop. The re-exports exist mainly for the macros (for the types to exist at a known path whether or not the time crate is explicitly added as a dependency) and documentation purposes.

It is not that hard to add time as a dependency. Specify a compatible version number and cargo update will take care of the rest:

# You should also enable the features you're actually using
time = { version = "0.3", features = ["formatting", "parsing", "macros"] }

This also gives you access to anything else in the time crate you might need down the road.

If/when time 0.4 or 1.0.0 comes out, that will also involve a major release for SQLx. It won't just break out of nowhere unless you have something like sqlx = "*".

@abonander abonander closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants