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

#[derive(Fields)] macro runs into type errors #7

Open
ChetanBhasin opened this issue Nov 11, 2024 · 2 comments
Open

#[derive(Fields)] macro runs into type errors #7

ChetanBhasin opened this issue Nov 11, 2024 · 2 comments

Comments

@ChetanBhasin
Copy link
Contributor

I've spent some time trying to understand what's going on but without much luck since I don't really know the intention of the types.

error[E0053]: method `sea_idens` has an incompatible type for trait
 --> src/model/user.rs:5:24
  |
5 | #[derive(Debug, Clone, Fields, FromRow)]
  |                        ^^^^^^ expected `SeaRc<dyn Iden>`, found `SeaRc<(dyn Iden + 'static)>`
  |
  = note: expected signature `fn() -> Vec<sea_query::types::SeaRc<(dyn sea_query::types::Iden + 'static)>>`
             found signature `fn() -> Vec<SeaRc<(dyn Iden + 'static)>>`
  = note: this error originates in the derive macro `Fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0053]: method `sea_column_refs` has an incompatible type for trait
 --> src/model/user.rs:5:24
  |
5 | #[derive(Debug, Clone, Fields, FromRow)]
  |                        ^^^^^^ expected `sea_query::types::ColumnRef`, found `ColumnRef`
  |
  = note: expected signature `fn() -> Vec<sea_query::types::ColumnRef>`
             found signature `fn() -> Vec<ColumnRef>`
  = note: this error originates in the derive macro `Fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0053]: method `sea_column_refs_with_rel` has an incompatible type for trait
 --> src/model/user.rs:5:24
  |
5 | #[derive(Debug, Clone, Fields, FromRow)]
  |                        ^^^^^^ expected `sea_query::types::ColumnRef`, found `ColumnRef`
  |
  = note: expected signature `fn(_) -> Vec<sea_query::types::ColumnRef>`
             found signature `fn(_) -> Vec<ColumnRef>`
  = note: this error originates in the derive macro `Fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `SIden: IntoIden` is not satisfied
 --> src/model/user.rs:5:24
  |
5 | #[derive(Debug, Clone, Fields, FromRow)]
  |                        ^^^^^^ the trait `Iden` is not implemented for `SIden`, which is required by `SIden: IntoIden`
  |
  = help: the following other types implement trait `Iden`:
            Alias
            MySqlType
            NullAlias
            sea_query::extension::postgres::PgLTree
  = note: required for `SIden` to implement `IntoIden`
  = note: this error originates in the derive macro `Fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the method `into_iden` exists for struct `SIden`, but its trait bounds were not satisfied
  --> src/model/user.rs:5:24
   |
5  | #[derive(Debug, Clone, Fields, FromRow)]
   |                        ^^^^^^
   |
  ::: /Users/chetan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/modql-0.4.0/src/sea_utils.rs:19:1
   |
19 | pub struct SIden(pub &'static str);
   | ---------------- doesn't satisfy `SIden: Iden` or `SIden: IntoIden`
   |
   = note: the following trait bounds were not satisfied:
           `SIden: Iden`
           which is required by `SIden: IntoIden`
           `&SIden: Iden`
           which is required by `&SIden: IntoIden`
           `&mut SIden: Iden`
           which is required by `&mut SIden: IntoIden`
   = help: items from traits can only be used if the trait is in scope
   = note: this error originates in the derive macro `Fields` (in Nightly builds, run with -Z macro-backtrace for more info)
help: trait `IntoIden` which provides `into_iden` is implemented but not in scope; perhaps you want to import it
   |
1  + use sea_query::types::IntoIden;
   |

Above is an example trace. Note that importing sea_query::types::IntoIden; does nothing.

@ChetanBhasin
Copy link
Contributor Author

Just wanted to update this with the information that this only takes place with sea-query 0.32. I also noticed that if you don't mark the inner fields pub in 0.31 for the structure on which you're trying to call the derive macro results in the same issue.

I'd be happy to help, but couldn't understand what's causing this.

@ChetanBhasin
Copy link
Contributor Author

Okay, looks like this just required a version bump: #8

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

No branches or pull requests

1 participant