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

AnyEncode is being removed but not mentioned in CHANGELOG #2598

Closed
billy1624 opened this issue Jul 7, 2023 · 2 comments
Closed

AnyEncode is being removed but not mentioned in CHANGELOG #2598

billy1624 opened this issue Jul 7, 2023 · 2 comments
Labels

Comments

@billy1624
Copy link
Contributor

Bug Description

I guess it's not intended to remove the capability to encode "common" values of all database drivers.

We have this AnyEncode trait in v0.6.x

image

https://docs.rs/sqlx/0.6.3/sqlx/trait.Encode.html#impl-Encode%3C'q,+Any%3E-for-Option%3CT%3E

However, it has been removed since v0.7.x in this PR, https://github.com/launchbadge/sqlx/pull/2039/files#diff-171f0c0ada41fb71384e917f3b78cb779c3a55e6fad6e7ac183511538c2d8840

Minimal Reproduction

Before upgrading to SQLx v0.7.x, https://github.com/SeaQL/sea-query/actions/runs/5437420800/jobs/9887963394#step:4:383

After upgrading to SQLx v0.7.x, https://github.com/SeaQL/sea-query/actions/runs/5484436965/jobs/9991980807?pr=652#step:4:395, CI of PR SeaQL/sea-query#652

Info

  • SQLx version: v0.7.0
  • SQLx features enabled: postgres,sqlite,any,mysql,chrono
  • Database server and version: MySQL, Postgres, SQLite, Any
  • Operating system: Ubuntu 22.04 LTS
  • rustc --version: 1.70.0 (90c541806 2023-05-31)
@abonander
Copy link
Collaborator

The AnyEncode trait is no longer needed as the relationship was inverted: for a database to support conversion to the Any driver, it must support all the types that the Any driver does.

Thus, Encode<Any> should be sufficient now.

@billy1624
Copy link
Contributor Author

billy1624 commented Jul 12, 2023

Hey @abonander, thanks for the attention! As far as I know we cannot encode types like NaiveDate, NaiveDateTime, etc, on Any driver.

image
error[E0277]: the trait bound `NaiveDate: Encode<'_, sqlx::Any>` is not satisfied
  --> src/sqlx_any.rs:54:30
   |
54 |                     args.add(d.map(|d| *d));
   |                          --- ^^^^^^^^^^^^^ the trait `Encode<'_, sqlx::Any>` is not implemented for `NaiveDate`
   |                          |
   |                          required by a bound introduced by this call
   |
   = help: the following other types implement trait `Encode<'q, DB>`:
             <NaiveDate as Encode<'_, MySql>>
             <NaiveDate as Encode<'_, Postgres>>
             <NaiveDate as Encode<'_, Sqlite>>
   = note: required for `Option<NaiveDate>` to implement `Encode<'_, sqlx::Any>`
note: required by a bound in `sqlx::Arguments::add`
  --> /Users/billy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.7.0/src/arguments.rs:19:24
   |
19 |         T: 'q + Send + Encode<'q, Self::Database> + Type<Self::Database>;
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Arguments::add`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants