-
Notifications
You must be signed in to change notification settings - Fork 5
fix: allow sqlx chrono and time features to be enabled
#35
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
base: main
Are you sure you want to change the base?
Conversation
|
Have you looked at https://github.com/orgs/apalis-dev/discussions/649? |
|
Ah, I did not see that! That would be another option. For me personally, and I think in general, both are suitable solutions. I would still add the explicit type casts (like in this PR), to avoid the case, where a user wants to use the |
|
I will look at this tomorrow, but its always encouraged to create an issue/discussion before a PR. |
|
Wouldn't this approach force |
|
@Stupremee Please respond to the question above |
geofmureithi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your PR doesnt seem to solve the actual issue at hand. Can you actually demonstrate that you can choose between chrono and time? adding an example and some tests should be the bear minimum.
| # you must cast all types in the query macros to the chrono type, because | ||
| # by default `sqlx` choses the datetime types from `time`. | ||
| # | ||
| # By adding this line to dev-dependencies, `cargo test` will run with both features enabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not about cargo test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your goal should be to allow both crates to be usable using a feature flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not about choosing time or chrono for apalis-postgres. This pull request is only meant to make it possible to compile apalis-postgres if sqlx has both features enabled.
@geofmureithi I had this change lying around on my PC for quite a while now, because I was using a vendored version of the crate. Then I figured I would just open a PR real quick. Sorry for the inconvenience, I should have opened an issue first!
I didn't change anything in the public API, so the crate for the user still stays the same. Right now, the user is just not able to have a You can still easily add configurable time backends. This pull request only makes sure, that In this repository you can find the reproduction of the bug I mean. |
|
The problem here seems to be trying to do this: Instead, the recommended approach IMO is to separate the |
|
But if I want to queue jobs from my backend application, I must have Because if that's the case, then the compilation error occurs, because I also have |
|
You dont have to have all the deps in the backend's Cargo.toml, you can create another crate and depend on it in the backend application. I would encourage experimenting with that first. Something like: package.name = "backend"
...
[dependencies]
worker-crate = "..path1"
models-crate = "..path2" |
|
This will not work because of feature unification. cargo will collect all |
|
You still have: |
|
Let's say I use the |
|
This problem seems to be more related to As noted, there is already a discussion on this issue and I think that will solve your current problem. I dont currently have the bandwidth to help you debug your problem. I will make a basic attempt on the approach discussed and update my findings there. |
|
Yes it's a common pitfall with sqlx. There are multiple crates with the same problem. This pull request fixes it by explicitly casting all date time values to chrono types. If you switch out apalis-postgres with my fork, the project compiles fine. |
|
As I said, this is not a complete solution because it does not:
Your PR should remain open as I think through this and experiment a little bit more. You should be able to use your fork as a dependency via git for now. |
|
Yes full |
|
Is this issue happening in 0.7.x? |
|
Are you sure?? 0.7 does not use |
|
My bad, 0.7.x is not affected 😅 |
126bf8d to
eb76a8b
Compare
|
I think then it should be ok for now. 0.7 should be what you should be using if you need a stable experience. 1.0 is still not stable and should be considered the wild west. I will spend some more time on this hopefully tomorrow and will do your contribution justice. I dont think this waiting some few more days would be a major issue. |
Description
Similar to pgmq/pgmq#401
Type of Change
Testing
cargo fmtandcargo clippyChecklist
Additional Notes
Any additional information, context, or screenshots about the pull request here.