pub fn sql<ST>(sql: &str) -> SqlLiteral<ST> where
Use literal SQL in the query builder
Available for when you truly cannot represent something using the expression DSL. You will need to provide the SQL type of the expression, in addition to the SQL.
This function is intended for use when you need a small bit of raw SQL in
your query. If you want to write the entire query using raw SQL, use
The compiler will be unable to verify the correctness of the annotated type. If you give the wrong type, it'll either return an error when deserializing the query result or produce unexpected values.
use diesel::dsl::sql; let user = users.filter(sql::<Bool>("name = 'Sean'")).first(&connection)?; let expected = (1, String::from("Sean")); assert_eq!(expected, user);