New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug_sql! #41

Closed
mfpiccolo opened this Issue Dec 2, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@mfpiccolo
Collaborator

mfpiccolo commented Dec 2, 2015

It would be really great if you could debug sql commands at compile time. Something like:

debug_sql!(users.filter(id.eq(1));

would output:

SELECT * FROM users WHERE id = 1

Or:

debug_sql!(update(users::table.filter(id.eq(id))).set(changed_user));

prints to console:

UPDATE "users" SET "name" = $1, "email" = $2 WHERE "users"."id" = $3 RETURNING "users"."id", "users"."name", "users"."email"
@sgrif

This comment has been minimized.

Member

sgrif commented Dec 2, 2015

Note: I don't think this needs to be a compiler plugin. We just need a DebugQueryBuilder that doesn't need a database connection, and have the macro expand to:

let mut query_builder = DebugQueryBuilder::new();
$query.to_sql(&mut query_builder).unwrap();
println!("{}", &query_builder.sql);

@mfpiccolo mfpiccolo referenced this issue Dec 4, 2015

Merged

Debug sql #46

@mfpiccolo mfpiccolo changed the title from debug_sql! compiler plugin to debug_sql! Dec 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment