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?
You are using a prepared statement. Within the call to bind, sqlx expects the value to interpolate for the query. If mytime is an optional value, you can do mytime.unwrap_or(sqlx::types::time::OffsetDateTime::now_utc())for example.
Thanks. that is creating a local date, as in the point of view of the client. I was expecting something akin to sending the call to "NOW()" on the sql statement, which would get the time from the database host.
Yup, I undertood that, that's why I started by saying that you're in a prepared statement; that is, you're in Rust's land when you are calling the bind method, not in SQL's land.