use crate::traits::QueryEngine;
#[diagnostic::on_unimplemented(
message = "the engine `{Self}` does not support relation filters (`some` / `every` / `none` / `is` / `is_not`)",
note = "ScyllaDB / Cassandra do not support correlated subqueries. Consider flattening the join or restructuring the model."
)]
pub trait SupportsRelationFilter: QueryEngine {}
#[diagnostic::on_unimplemented(
message = "the engine `{Self}` does not support correlated subqueries in WHERE clauses"
)]
pub trait SupportsCorrelatedSubquery: QueryEngine {}
#[diagnostic::on_unimplemented(
message = "the engine `{Self}` does not support JSON path operators",
note = "Postgres / MySQL >= 5.7 / SQLite + JSON1 / MSSQL support JSON paths."
)]
pub trait SupportsJsonPath: QueryEngine {}
#[diagnostic::on_unimplemented(
message = "the engine `{Self}` does not advertise native case-insensitive comparison"
)]
pub trait SupportsCaseInsensitiveMode: QueryEngine {}
#[diagnostic::on_unimplemented(message = "the engine `{Self}` does not support full-text search")]
pub trait SupportsFullTextSearch: QueryEngine {}
#[diagnostic::on_unimplemented(message = "the engine `{Self}` does not support array operators")]
pub trait SupportsArrayOps: QueryEngine {}
#[diagnostic::on_unimplemented(
message = "the engine `{Self}` does not support generated columns",
note = "Postgres / MySQL / SQLite / MSSQL / DuckDB support GENERATED ALWAYS AS."
)]
pub trait SupportsGeneratedColumns: QueryEngine {}
#[diagnostic::on_unimplemented(
message = "the engine `{Self}` does not support scalar subqueries in SELECT",
note = "All SQL engines satisfy this. MongoDB requires the $lookup-lowering follow-up plan."
)]
pub trait SupportsScalarSubqueryInSelect: QueryEngine {}
#[diagnostic::on_unimplemented(
message = "the engine `{Self}` does not support nested writes",
note = "ScyllaDB / Cassandra batch semantics don't map onto Prisma-style nested writes. Use the engine-native BATCH API or restructure."
)]
pub trait SupportsNestedWrites: QueryEngine {}
#[cfg(test)]
mod tests {
use super::*;
#[derive(Clone)]
struct StubEngine;
impl QueryEngine for StubEngine {
fn query_many<T: crate::traits::Model + crate::row::FromRow + Send + 'static>(
&self,
_sql: &str,
_params: Vec<crate::filter::FilterValue>,
) -> crate::traits::BoxFuture<'_, crate::error::QueryResult<Vec<T>>> {
Box::pin(async { Ok(Vec::new()) })
}
fn query_one<T: crate::traits::Model + crate::row::FromRow + Send + 'static>(
&self,
_sql: &str,
_params: Vec<crate::filter::FilterValue>,
) -> crate::traits::BoxFuture<'_, crate::error::QueryResult<T>> {
Box::pin(async { Err(crate::error::QueryError::not_found("t")) })
}
fn query_optional<T: crate::traits::Model + crate::row::FromRow + Send + 'static>(
&self,
_sql: &str,
_params: Vec<crate::filter::FilterValue>,
) -> crate::traits::BoxFuture<'_, crate::error::QueryResult<Option<T>>> {
Box::pin(async { Ok(None) })
}
fn execute_insert<T: crate::traits::Model + crate::row::FromRow + Send + 'static>(
&self,
_sql: &str,
_params: Vec<crate::filter::FilterValue>,
) -> crate::traits::BoxFuture<'_, crate::error::QueryResult<T>> {
Box::pin(async { Err(crate::error::QueryError::not_found("t")) })
}
fn execute_update<T: crate::traits::Model + crate::row::FromRow + Send + 'static>(
&self,
_sql: &str,
_params: Vec<crate::filter::FilterValue>,
) -> crate::traits::BoxFuture<'_, crate::error::QueryResult<Vec<T>>> {
Box::pin(async { Ok(Vec::new()) })
}
fn execute_delete(
&self,
_sql: &str,
_params: Vec<crate::filter::FilterValue>,
) -> crate::traits::BoxFuture<'_, crate::error::QueryResult<u64>> {
Box::pin(async { Ok(0) })
}
fn execute_raw(
&self,
_sql: &str,
_params: Vec<crate::filter::FilterValue>,
) -> crate::traits::BoxFuture<'_, crate::error::QueryResult<u64>> {
Box::pin(async { Ok(0) })
}
fn count(
&self,
_sql: &str,
_params: Vec<crate::filter::FilterValue>,
) -> crate::traits::BoxFuture<'_, crate::error::QueryResult<u64>> {
Box::pin(async { Ok(0) })
}
}
impl SupportsRelationFilter for StubEngine {}
fn needs_relation_filter<E: SupportsRelationFilter>() {}
#[test]
fn marker_trait_dispatch_compiles() {
needs_relation_filter::<StubEngine>();
}
}