Skip to content

Weird the trait bound f64: From<Option<f64>> is not satisfied-error in sqlx-turso prepare #1

Description

@Jazzpirate

I'm getting a weird error I don't understand, and unfortunately can't debug properly since the issue is in the query_as macro during sqlx_prepare, so I can't see the macro expansion either.

I have a migration that roughly looks like this:

CREATE TABLE IF NOT EXISTS competencies
(
    learner_id INTEGER           NOT NULL REFERENCES learners(id),
    concept_id INTEGER           NOT NULL REFERENCES concepts(id),
    remember   DOUBLE PRECISION  NOT NULL DEFAULT 0.0,
    understand DOUBLE PRECISION  NOT NULL DEFAULT 0.0,
    apply      DOUBLE PRECISION  NOT NULL DEFAULT 0.0,
    "analyse"  DOUBLE PRECISION  NOT NULL DEFAULT 0.0,
    evaluate   DOUBLE PRECISION  NOT NULL DEFAULT 0.0,
    "create"   DOUBLE PRECISION  NOT NULL DEFAULT 0.0,
    PRIMARY KEY (learner_id, concept_id)
);

and a table row

#[derive(Clone, Debug, Default,sqlx_turso::sqlx::FromRow)]
pub struct Competency {
    pub remember: f64,
    pub understand: f64,
    pub apply: f64,
    pub analyse: f64,
    pub evaluate: f64,
    pub create: f64,
}

...but if I try to query it as such:

sqlx_turso::query_as!(
        Competency,
        r#"
        SELECT c.remember, c.understand, c.apply, c."analyse", c.evaluate, c."create"
        FROM competencies c
        JOIN learners l ON l.id = c.learner_id
        JOIN concepts k ON k.id = c.concept_id
        WHERE l.identifier = ? AND k.identifier = ?
        "#,
        user_ident,
        uri
    )

...then running sqlx-turso prepare throws the trait bound f64: From<Option<f64>> is not satisfied somewhere in the macro invocation. Notably, it works with vanilla sqlx and sqlite. Any idea what I'm doing wrong or need to do differently?

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