Alright, i need a method to get the final SQL query that diesel would run against the DB. I want to keep using diesel to build the queries and get all the benefits that diesel provides. But i would also like to transition to a HTTP based DB query protocol.
I know there is debug_query, but that still has the bind parameters not replaced. Does anyone know of a good solution?
Diesel does not substitute these bind parameters at all. It sends the query and the bind parameters separately to the database. Substitution is done there. That means diesel cannot easily provide an query with "bind parameters replaced" as that representation just does not exist inside of diesel.
If you need to access the query and the bind parameters for anything else than debugging purposes, you likly want to use the QueryFragment::to_sql
and QueryFragment::collect_binds
methods instead of using debug_query
.