diff --git a/examples/rocket_example/src/main.rs b/examples/rocket_example/src/main.rs index 9a55deac..8dd92fca 100644 --- a/examples/rocket_example/src/main.rs +++ b/examples/rocket_example/src/main.rs @@ -6,12 +6,12 @@ use rocket::form::{Context, Form}; use rocket::fs::{relative, FileServer}; use rocket::request::FlashMessage; use rocket::response::{Flash, Redirect}; -use rocket::serde::json::Json; use rocket::{Build, Request, Rocket}; use rocket_db_pools::{sqlx, Connection, Database}; use rocket_dyn_templates::{context, Template}; use sea_orm::entity::*; +use sea_orm::QueryOrder; use sea_orm::RocketDbPool; mod setup; @@ -72,6 +72,7 @@ async fn update(conn: Connection, id: i64, post_form: Form) -> #[get("/")] async fn list(conn: Connection, flash: Option>) -> Template { let posts = Post::find() + .order_by_asc(post::Column::Id) .all(&conn) .await .expect("could not retrieve posts") diff --git a/examples/rocket_example/static/css/style.css b/examples/rocket_example/static/css/style.css index 62c2f904..ac2720d3 100644 --- a/examples/rocket_example/static/css/style.css +++ b/examples/rocket_example/static/css/style.css @@ -58,9 +58,6 @@ button.small { margin: 0 2.5px; } -.post { -} - .post:hover { background-color: #bce2ee; } diff --git a/src/executor/query.rs b/src/executor/query.rs index 08728081..d880063d 100644 --- a/src/executor/query.rs +++ b/src/executor/query.rs @@ -103,6 +103,7 @@ macro_rules! try_getable_all { .and_then(|opt| opt.ok_or(TryGetError::Null)) } #[cfg(feature = "mock")] + #[allow(unused_variables)] QueryResultRow::Mock(row) => row.try_get(column.as_str()).map_err(|e| { debug_print!("{:#?}", e.to_string()); TryGetError::Null @@ -138,6 +139,7 @@ macro_rules! try_getable_unsigned { .and_then(|opt| opt.ok_or(TryGetError::Null)) } #[cfg(feature = "mock")] + #[allow(unused_variables)] QueryResultRow::Mock(row) => row.try_get(column.as_str()).map_err(|e| { debug_print!("{:#?}", e.to_string()); TryGetError::Null @@ -170,6 +172,7 @@ macro_rules! try_getable_mysql { panic!("{} unsupported by sqlx-sqlite", stringify!($type)) } #[cfg(feature = "mock")] + #[allow(unused_variables)] QueryResultRow::Mock(row) => row.try_get(column.as_str()).map_err(|e| { debug_print!("{:#?}", e.to_string()); TryGetError::Null @@ -202,6 +205,7 @@ macro_rules! try_getable_postgres { panic!("{} unsupported by sqlx-sqlite", stringify!($type)) } #[cfg(feature = "mock")] + #[allow(unused_variables)] QueryResultRow::Mock(row) => row.try_get(column.as_str()).map_err(|e| { debug_print!("{:#?}", e.to_string()); TryGetError::Null @@ -264,12 +268,16 @@ impl TryGetable for Decimal { .map_err(|e| TryGetError::DbErr(crate::sqlx_error_to_query_err(e)))?; use rust_decimal::prelude::FromPrimitive; match val { - Some(v) => Decimal::from_f64(v) - .ok_or_else(|| TryGetError::DbErr(DbErr::Query("Failed to convert f64 into Decimal".to_owned()))), - None => Err(TryGetError::Null) + Some(v) => Decimal::from_f64(v).ok_or_else(|| { + TryGetError::DbErr(DbErr::Query( + "Failed to convert f64 into Decimal".to_owned(), + )) + }), + None => Err(TryGetError::Null), } } #[cfg(feature = "mock")] + #[allow(unused_variables)] QueryResultRow::Mock(row) => row.try_get(column.as_str()).map_err(|e| { debug_print!("{:#?}", e.to_string()); TryGetError::Null