#[cfg(all(
not(feature = "sqlite-rusqlite"),
not(feature = "postgres-tokio-postgres")
))]
pub trait RowDecode:
Sized
+ Send
+ Sync
+ 'static
+ for<'r> sqlx::FromRow<'r, sqlx::any::AnyRow>
+ for<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow>
+ for<'r> sqlx::FromRow<'r, sqlx::sqlite::SqliteRow>
+ for<'r> sqlx::FromRow<'r, sqlx::mysql::MySqlRow>
{
}
#[cfg(all(feature = "sqlite-rusqlite", not(feature = "postgres-tokio-postgres")))]
pub trait RowDecode:
Sized
+ Send
+ Sync
+ 'static
+ for<'r> sqlx::FromRow<'r, sqlx::any::AnyRow>
+ for<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow>
+ for<'r> sqlx::FromRow<'r, sqlx::sqlite::SqliteRow>
+ for<'r> sqlx::FromRow<'r, sqlx::mysql::MySqlRow>
+ crate::rusqlite::FromRusqliteRow
+ crate::rusqlite::FromOwnedRow
{
}
#[cfg(all(not(feature = "sqlite-rusqlite"), feature = "postgres-tokio-postgres"))]
pub trait RowDecode:
Sized
+ Send
+ Sync
+ 'static
+ for<'r> sqlx::FromRow<'r, sqlx::any::AnyRow>
+ for<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow>
+ for<'r> sqlx::FromRow<'r, sqlx::sqlite::SqliteRow>
+ for<'r> sqlx::FromRow<'r, sqlx::mysql::MySqlRow>
+ crate::tokio_postgres::FromTokioPostgresRow
{
}
#[cfg(all(feature = "sqlite-rusqlite", feature = "postgres-tokio-postgres"))]
pub trait RowDecode:
Sized
+ Send
+ Sync
+ 'static
+ for<'r> sqlx::FromRow<'r, sqlx::any::AnyRow>
+ for<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow>
+ for<'r> sqlx::FromRow<'r, sqlx::sqlite::SqliteRow>
+ for<'r> sqlx::FromRow<'r, sqlx::mysql::MySqlRow>
+ crate::rusqlite::FromRusqliteRow
+ crate::rusqlite::FromOwnedRow
+ crate::tokio_postgres::FromTokioPostgresRow
{
}
#[cfg(all(
not(feature = "sqlite-rusqlite"),
not(feature = "postgres-tokio-postgres")
))]
impl<T> RowDecode for T where
T: Sized
+ Send
+ Sync
+ 'static
+ for<'r> sqlx::FromRow<'r, sqlx::any::AnyRow>
+ for<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow>
+ for<'r> sqlx::FromRow<'r, sqlx::sqlite::SqliteRow>
+ for<'r> sqlx::FromRow<'r, sqlx::mysql::MySqlRow>
{
}
#[cfg(all(feature = "sqlite-rusqlite", not(feature = "postgres-tokio-postgres")))]
impl<T> RowDecode for T where
T: Sized
+ Send
+ Sync
+ 'static
+ for<'r> sqlx::FromRow<'r, sqlx::any::AnyRow>
+ for<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow>
+ for<'r> sqlx::FromRow<'r, sqlx::sqlite::SqliteRow>
+ for<'r> sqlx::FromRow<'r, sqlx::mysql::MySqlRow>
+ crate::rusqlite::FromRusqliteRow
+ crate::rusqlite::FromOwnedRow
{
}
#[cfg(all(not(feature = "sqlite-rusqlite"), feature = "postgres-tokio-postgres"))]
impl<T> RowDecode for T where
T: Sized
+ Send
+ Sync
+ 'static
+ for<'r> sqlx::FromRow<'r, sqlx::any::AnyRow>
+ for<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow>
+ for<'r> sqlx::FromRow<'r, sqlx::sqlite::SqliteRow>
+ for<'r> sqlx::FromRow<'r, sqlx::mysql::MySqlRow>
+ crate::tokio_postgres::FromTokioPostgresRow
{
}
#[cfg(all(feature = "sqlite-rusqlite", feature = "postgres-tokio-postgres"))]
impl<T> RowDecode for T where
T: Sized
+ Send
+ Sync
+ 'static
+ for<'r> sqlx::FromRow<'r, sqlx::any::AnyRow>
+ for<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow>
+ for<'r> sqlx::FromRow<'r, sqlx::sqlite::SqliteRow>
+ for<'r> sqlx::FromRow<'r, sqlx::mysql::MySqlRow>
+ crate::rusqlite::FromRusqliteRow
+ crate::rusqlite::FromOwnedRow
+ crate::tokio_postgres::FromTokioPostgresRow
{
}
pub trait Model: RowDecode {
const TABLE: &'static str;
const PRIMARY_KEY: &'static str = "id";
const COLUMNS: &'static [&'static str] = &[];
const DELETED_AT_COLUMN: Option<&'static str> = None;
const UPDATED_AT_COLUMN: Option<&'static str> = None;
}
pub(crate) fn live_rows_node<M: Model>(table: &'static str) -> Option<crate::filter::FilterNode> {
M::DELETED_AT_COLUMN.map(|column| crate::filter::FilterNode::Null {
table,
column,
negated: false,
})
}
pub(crate) fn live_rows<M: Model>() -> crate::filter::Filter<M> {
crate::filter::Filter::new(
live_rows_node::<M>(M::TABLE).unwrap_or_else(|| crate::filter::FilterNode::And(Vec::new())),
)
}