Skip to content

[Feature] Add [must_use] attribute and implement IntoFuture for D1PreparedStatement #774

@lexoliu

Description

@lexoliu

Is there an existing issue for this?

  • I have searched the existing issues

Description

D1PreparedStatement is just a statement, which has not been executed actually. However, user could make mistake by writing code like this:

query!(&self.db, "DELETE FROM users WHERE id = ?", id)?; // correct version: query!(&self.db, "DELETE FROM users WHERE id = ?", id)?.all().await?

This code does not work, D1PreparedStatement just like a Future in Rust. It wouldn't been executed automatically, it must been called explicitly .

I suggest that we could implement IntoFuture for D1PreparedStatement, so that we can execute a statement by await it directly. What's more, D1PreparedStatement need to been attributed as #[must_use], to avoid misuse statically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions