Skip to content

SQLite3: PrimitiveDateTime cannot be used in macros #3624

@moubctez

Description

@moubctez

Bug Description

When a field is defined PrimitiveDateTime it cannot be fetched from SQLite3 database using a macro.
Compiler emits: the trait From<OffsetDateTime> is not implemented for PrimitiveDateTime, which is required by OffsetDateTime: Into<_>

The query_as! macro gets expanded to something contaning:

#[allow(non_snake_case)]
let sqlx_query_as_last_check = row.try_get_unchecked:: <sqlx::types::time::OffsetDateTime,_>(5usize)? .into();           

Minimal Reproduction

struct Package {
    id: i64
    last_check: PrimitiveDateTime,
}

impl Package {
    async fn get(pool: &SqlitePool, id: i64) -> Result<Self, SqlxError> {
        query_as!(
            Self,
            "SELECT last_check FROM package WHERE id = $1",
            id
        )
        .fetch_one(pool)
        .await
    }
}

Info

  • SQLx version: v0.8.2
  • SQLx features enabled: "runtime-tokio-native-tls", "sqlite", "time"
  • Database server and version: SQLite 3.47.1
  • Operating system: macOS (Darwin Kernel Version 24.2.0)
  • rustc --version: rustc 1.83.0 (90b35a623 2024-11-26) (built from a source tarball)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions