nodecosmos / charybdis

Rust ORM for ScyllaDB and Apache Cassandra
MIT License
108 stars 6 forks source link

Raw Query Dump #13

Open DanielHe4rt opened 3 months ago

DanielHe4rt commented 3 months ago

Hey Goran!

There's any way to dump the raw query before it get executed for debugging purposes?

GoranBrkuljan commented 3 months ago

ATM we can do it for insert, update and delete queries by doing following:

let caching_session: CachingSession;

let res = model.insert().trace(true).execute(caching_session).await?;
if let Some(tracing_id) = res.tracing_id {
    let info = caching_session
        .get_session()
        .get_tracing_info(&tracing_id)
        .await
        .unwrap();
    // log query
    info!("Info: {:#?}", info.parameters);
}

For read queries we return typed results, so we would need to update our CharybdisQuery execution logic to enable this. I will do it when I get a chance, so let's leave this thread open for now.

GoranBrkuljan commented 3 months ago

Additionally, in case of error you can also cover read query by printing CharybdisError as it always print static query that is generated at compile time, however it does not contain values.