Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Sqlx, possible to use sql's "NOW()"
I have a field that holds a timestamp.
I'm inserting with two different queries, one that doesn't contain the field on the list of data being inserted, to abuse the DEFAULT NOW()
on that field, but the ideal solution would be something like:
let mytime: Option<sqlx::types::time::OffsetDateTime> = ...;
let db_result = sqlx::query("INSERT INTO
table (mytimestamp)
VALUES ($1);")
.bind(mytime.or(sqlx::something::now))
Is there any way to tell sqlx that I want a value of a function call?
5 posts - 3 participants
🏷️ rust_feed