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

[BUG] DerivePartialModel attr entity not support syn::Path token #2113

Open
Goodjooy opened this issue Feb 18, 2024 · 3 comments
Open

[BUG] DerivePartialModel attr entity not support syn::Path token #2113

Goodjooy opened this issue Feb 18, 2024 · 3 comments

Comments

@Goodjooy
Copy link
Contributor

Description

DerivePartialModel will produce error when set entity as path::to::entity::Entity

Steps to Reproduce

  1. prepare an Entity, using cake for example
  2. define the partial model like following
#[derive(FromQueryResult, DerivePartialModel)]
#[sea_orm(entity="cake::Entity")]
struct CakePartial{
   .. // fields
}
  1. get the macro error :
error: unexpected token                                                                                                                                                                                                            
  --> src\service\child_statical.rs:48:45
   |
48 | #[derive(FromQueryResult, DerivePartialModel)]
   |                           ^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the derive macro `DerivePartialModel` (in Nightly builds, run with -Z macro-backtrace for more info)

Expected Behavior

the macro should accept the entity as a Path token

Actual Behavior

The macro only accept Ident token

Workarounds

  1. using the Cake in the src/entities/prelude ( the src/entities is the out put dir of the command sea-orm-cli generate entity)
  2. using a local mod use the entity, like following
mod local_quiz {
            use crate::entities::quizes::Entity;
            use sea_orm::DerivePartialModel;
            use sea_orm::FromQueryResult;
            #[derive(Debug, FromQueryResult, DerivePartialModel)]
            #[sea_orm(entity = "Entity")]
            pub(super) struct Quiz {
                pub(super) qid: i32,
                pub(super) quiz: String,
            }
        }

Versions

????? sea-orm v0.12.12
?? ????? sea-orm-macros v0.12.12 (proc-macro)
?? ?? ????? sea-bae v0.2.0 (proc-macro)
?? ????? sea-query v0.30.7
?? ????? sea-query-binder v0.5.0
?? ?? ????? sea-query v0.30.7 (*)

@Goodjooy Goodjooy changed the title [BUG] DerivePartialModel attr entity not support Path token [BUG] DerivePartialModel attr entity not support syn::Path token Feb 18, 2024
@tyt2y3
Copy link
Member

tyt2y3 commented Mar 2, 2024

A PR would be appreciated!

@Goodjooy
Copy link
Contributor Author

Goodjooy commented Mar 3, 2024

A PR would be appreciated!

Here is the pr to fix this bug #2137

1 similar comment
@Goodjooy
Copy link
Contributor Author

Goodjooy commented Mar 3, 2024

A PR would be appreciated!

Here is the pr to fix this bug #2137

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

2 participants