When I deserializing from CURRENT_TIMESTAMP to chrono::DateTime<chrono::Utc>, serde_rusqlite::from_rows returns an error.
Dependencies
anyhow = "^1.0"
serde = { version = "^1.0", features = ["derive"] }
chrono = { version = "~0.4", features = ["serde"] }
rusqlite = { version = "~0.31", features = ["bundled"] }
serde_rusqlite = "~0.35"
Code
use anyhow::Result;
use chrono::{DateTime, Utc};
use rusqlite::Connection;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct Timed {
time: DateTime<Utc>
}
fn main() -> Result<()> {
let connection = Connection::open_in_memory()?;
connection.execute("CREATE TABLE test (time TIMESTAMP)", [])?;
connection.execute("INSERT INTO test (time) VALUES (CURRENT_TIMESTAMP)", [])?;
let mut statement = connection.prepare("SELECT * FROM test")?;
let mut iter = serde_rusqlite::from_rows::<Timed>(statement.query([])?);
while let Some(timed) = iter.next() {
let timed = timed?;
println!("{:?}", timed);
}
Ok(())
}
Print
Error: Deserialization failed for column: time error: premature end of input
Thought
This may not a bug in serde_rusqlite, but it will be great if this crate can handle this situation correctly.
When I deserializing from
CURRENT_TIMESTAMPtochrono::DateTime<chrono::Utc>,serde_rusqlite::from_rowsreturns an error.Dependencies
Code
Print
Thought
This may not a bug in
serde_rusqlite, but it will be great if this crate can handle this situation correctly.