sea_orm

Macro debug_query_stmt

Source
macro_rules! debug_query_stmt {
    ($query:expr,$value:expr) => { ... };
}
Expand description

Helper to get a Statement from an object that impl QueryTrait.

ยงExample

use sea_orm::{debug_query_stmt, entity::*, query::*, tests_cfg::cake};

let c = cake::Entity::insert(cake::ActiveModel {
    id: ActiveValue::set(1),
    name: ActiveValue::set("Apple Pie".to_owned()),
});

let raw_sql = debug_query_stmt!(&c, &conn).to_string();
assert_eq!(
    raw_sql,
    r#"INSERT INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#
);

let raw_sql = debug_query_stmt!(&c, conn).to_string();
assert_eq!(
    raw_sql,
    r#"INSERT INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#
);

let raw_sql = debug_query_stmt!(&c, DbBackend::MySql).to_string();
assert_eq!(
    raw_sql,
    r#"INSERT INTO `cake` (`id`, `name`) VALUES (1, 'Apple Pie')"#
);

let raw_sql = debug_query_stmt!(&c, &DbBackend::MySql).to_string();
assert_eq!(
    raw_sql,
    r#"INSERT INTO `cake` (`id`, `name`) VALUES (1, 'Apple Pie')"#
);