Skip to content

BitVec Serde support #2995

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

Closed
bakageddy opened this issue Jan 16, 2024 · 2 comments
Closed

BitVec Serde support #2995

bakageddy opened this issue Jan 16, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@bakageddy
Copy link

bakageddy commented Jan 16, 2024

Is your feature request related to a problem? Please describe.
Currently bitvec crate supports serde as a optional feature. I would like to see that included in sqlx since I don't want to implement a custom deserializer and serializer for that type.

Describe the solution you'd like
Edit Cargo.toml and add feature "serde" for bitvec crate.

Describe alternatives you've considered
I have tried using the original crate, but since the original type does not support Decode trait in sqlx, I find it difficult to use it.

Additional context
I am relatively new to OSS but I have read the Contributing.md doc. It guided me to make a issue first and then proceed with a PR even though I imagine it's a simple one.

Cargo.toml:

sqlx = { version = "0.7.3", features = ["postgres", "runtime-tokio-rustls", "bit-vec"] }

Postgresql DB Version: 16.1

@bakageddy bakageddy added the enhancement New feature or request label Jan 16, 2024
@abonander
Copy link
Collaborator

abonander commented Jan 17, 2024

It's important to note that we're actually talking about two different crates with similar names:

  1. bit-vec by the contain-rs org.
    • SQLx already has support for this crate; that's actually the feature you have enabled in your Cargo.toml.
  2. bitvec by the ferrilab org.
    • This sounds like the one you're actually trying to use. Unfortunately, SQLx doesn't support it.

These are completely separate crates so their types aren't interchangeable.

If you were to switch to the bit-vec crate, all you'd have to do is add it to your own dependencies and enable the serde feature:

bit-vec = { version = "0.6.3", features = ["serde"] }

However, I'll admit that the authors of bitvec appear to have put a lot more work into it, and it's the more recently updated of the two.

The problem is, though, that I don't want to just have support for both because that could lead to a ton of confusion ("wait, am I supposed to be using the bit-vec crate or the bitvec crate?"), and we already have issues with the macros when multiple Rust types are applicable to the same SQL type and they're behind different optional features (#2689).

I wouldn't be against switching from bit-vec to bitvec but that's a breaking change, and an entirely separate discussion.

There just isn't a really good answer here, sorry.

@abonander abonander closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2024
@bakageddy
Copy link
Author

Actually, I apologize for my blunder. I tried to use bitvec crate instead of bit-vec crate. I did not know there were two separate crates, with the same feature flags. Thanks for clearing up the misunderstanding!

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

No branches or pull requests

2 participants