sea_orm

Macro debug_query

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

Helper to get a raw SQL string from an object that impl QueryTrait.

ยงExample

use sea_orm::{debug_query, 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!(&c, &conn);
assert_eq!(
    raw_sql,
    r#"INSERT INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#
);

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

let raw_sql = debug_query!(&c, DbBackend::Sqlite);
assert_eq!(
    raw_sql,
    r#"INSERT INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#
);