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

why delete_by_id function not receive &str args? #1361

Closed
baoyachi opened this issue Jan 4, 2023 · 3 comments · Fixed by #1362
Closed

why delete_by_id function not receive &str args? #1361

baoyachi opened this issue Jan 4, 2023 · 3 comments · Fixed by #1362
Assignees
Milestone

Comments

@baoyachi
Copy link
Contributor

baoyachi commented Jan 4, 2023

  • call delete_by_id function,compiled error.
+ pub async fn delete_by_id(id: &str) -> Result<()> {
    let db = get_connection()?;
    msg_cache::Entity::delete_by_id(id).exec(db).await?;
    Ok(())
}
  • The terminal compiled error detail:
   Compiling demo v0.1.1 (/Users/baoyachi/rust-project/demo)
error[E0308]: mismatched types
   --> src/db/msg_cache.rs:71:41
    |
71  |     msg_cache::Entity::delete_by_id(id).exec(db).await?;
    |     ----------------------------------- ^^- help: try using a conversion method: `.to_string()`
    |     |                                   |
    |     |                                   expected struct `std::string::String`, found `&str`
    |     arguments to this function are incorrect
    |
note: associated function defined here
   --> /Users/baoyachi/.cargo/registry/src/sea-orm-0.9.3/src/entity/base_entity.rs:822:8
    |
822 |     fn delete_by_id(values: <Self::PrimaryKey as PrimaryKeyTrait>::ValueType) -> DeleteMany<Self> {
    |        ^^^^^^^^^^^^
  • The table Generated Entity:
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "msg_cache")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: String,
    pub raw_val: String,
}
@baoyachi baoyachi changed the title why delete_by_id function not receiver &str? why delete_by_id function not receive &str args? Jan 4, 2023
@billy1624 billy1624 self-assigned this Jan 4, 2023
@billy1624
Copy link
Member

Hey @baoyachi, thanks for the suggestion! Yes, we can relax it by accepting any Into<<Self::PrimaryKey as PrimaryKeyTrait>::ValueType>. Please check #1362

@baoyachi
Copy link
Contributor Author

Thx @billy1624 . Expect the new version to use this feature

@billy1624
Copy link
Member

There will be a new release soon :)

@billy1624 billy1624 moved this from Triage to Done in SeaQL Dev Tracker Jan 13, 2023
@billy1624 billy1624 added this to the 0.11.x milestone Jan 31, 2023
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