refactor(db): declare unixepoch instead of formatting a SQL fragment
This commit is contained in:
12
server/crates/arbiter-server/src/db/functions.rs
Normal file
12
server/crates/arbiter-server/src/db/functions.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
//! Typed bindings for the SQLite scalar functions used in Diesel expressions.
|
||||
|
||||
use diesel::sql_types::{Integer, Text};
|
||||
|
||||
diesel::define_sql_function! {
|
||||
/// SQLite `unixepoch(modifier)` -- seconds since the Unix epoch.
|
||||
///
|
||||
/// Declared so timestamp comparisons are built by the query DSL instead of by
|
||||
/// `format!`-ing a SQL fragment: the argument becomes a bind parameter and the
|
||||
/// result type is checked against the column it is compared with.
|
||||
fn unixepoch(modifier: Text) -> Integer;
|
||||
}
|
||||
Reference in New Issue
Block a user