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

Eq is not implemented for Vec<f64> error when using "postgress-array" feature #1156

Closed
tjallingt opened this issue Oct 26, 2022 · 3 comments · Fixed by #1158
Closed

Eq is not implemented for Vec<f64> error when using "postgress-array" feature #1156

tjallingt opened this issue Oct 26, 2022 · 3 comments · Fixed by #1158
Assignees

Comments

@tjallingt
Copy link

Description

The "postgres-array" feature is not taken into account when generating Eq derives.
This causes the CLI to derive Eq for models containing Vec<f64> which will result in the following compilation error:

error[E0277]: the trait bound `f64: std::cmp::Eq` is not satisfied
   --> app\src\entities\sensor.rs:17:5
    |
6   | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
    |                                                      -- in this derive macro expansion
...
17  |     pub parameter_value: Vec<f64>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `f64`

Steps to Reproduce

  1. create the following table in a postgres database:
create table sensor (
    id uuid primary key default gen_random_uuid(),
    parameter_value double precision[] not null
);
  1. enable the "postgres-array" feature in Cargo.toml
sea-orm = { version = "0.10", features = [
  "sqlx-postgres",
  "runtime-tokio-native-tls",
  "macros",
  "postgres-array",
] }
  1. Run sea generate entity to generate the entities
  2. Check/compile the project

Expected Behavior

This should compile, no Eq derive on the "sensor" Model.

Actual Behavior

This does not compile, there is a Eq derive on the "sensor" Model.

Reproduces How Often

Always

Versions

sea-orm 0.10.0
sea-orm-cli 0.10.0

Additional Information

The Eq derive was added in this PR but the logic does not take into account floats inside Vecs #988

@billy1624
Copy link
Member

Hey @tjallingt, thanks for catching this!! I just fix it on this PR

We'll release a new patch shortly :)

@tjallingt
Copy link
Author

Thank you so much for the quick fix, love the project so far!

@billy1624
Copy link
Member

Thanks for the support and love :D

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

Successfully merging a pull request may close this issue.

2 participants