-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
add debug_query macro make get raw_sql becomes simply. #189
Conversation
Hey @baoyachi, if we change the Lines 16 to 23 in 6861802
Introduce a new trait pub trait IntoDbBackend { ... }
impl IntoDbBackend for DatabaseConnection { ... }
impl IntoDbBackend for DatabaseBackend { ... } Then we can write... let raw_sql = Entity::insert(pear).build(&db).to_string();
let raw_sql = Entity::insert(pear).build(DatabaseBackend::MySql).to_string(); |
@billy1624 That's great. I thought about this before sending PR, which may involve large changes. Now I think I can do that. |
Any comments? @tyt2y3 |
Okay so, I would prefer |
@tyt2y3 I have removed @billy1624 --> src/database/connection.rs:20:8
|
19 | pub trait IntoDbBackend {
| ------------- this trait cannot be made into an object...
20 | fn build(&self, statement: &impl StatementBuilder) -> Statement;
| ^^^^^ ...because method `build` has generic type parameters So I haven't modified this object for the time being. Let it remain as it is for the time being. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review. When I go through a PR, I'd actually try to justify every line change.
As such, the more line changes are there, the more effort it takes to go through.
Thank you for your contribution nonetheless!
Thank you |
Let's take insertion as an example,before we want get sea-orm raw_sql, it's may be import trait namespace with :
use sea_orm::QueryTrait;
Now, you can use
debug_query
macro get raw_sql becomes simply.It does not need to specify a specificDbBackend
,but can be obtained throughget_database_backend
function withDatabaseConnection
. That not import trait namespace, thedebug_query macro make use simply.
&DatabaseConnection
reference orDbBackend
type .Statement
to_string().