Skip to content

Commit c65a130

Browse files
authored
Merge pull request #305 from ikrivosheev/fix/issues-303_sqlx_option_box
issues-303 Fix bind_box! for sqlx
2 parents 09a75b7 + 757383e commit c65a130

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

sea-query-driver/src/sqlx_mysql.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ pub fn bind_params_sqlx_mysql_impl(input: TokenStream) -> TokenStream {
6969
};
7070
}
7171
macro_rules! bind_box {
72-
( $v: expr ) => {
73-
match $v {
74-
Some(v) => query.bind(v.as_ref()),
75-
None => query.bind(None::<bool>),
76-
}
77-
};
72+
( $v: expr ) => {{
73+
let v = match $v {
74+
Some(v) => Some(v.as_ref()),
75+
None => None,
76+
};
77+
query.bind(v)
78+
}};
7879
}
7980
query = match value {
8081
Value::Bool(v) => bind!(v, bool),

sea-query-driver/src/sqlx_postgres.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,13 @@ pub fn bind_params_sqlx_postgres_impl(input: TokenStream) -> TokenStream {
7575
};
7676
}
7777
macro_rules! bind_box {
78-
( $v: expr ) => {
79-
match $v {
80-
Some(v) => query.bind(v.as_ref()),
81-
None => query.bind(None::<bool>),
82-
}
83-
};
78+
( $v: expr ) => {{
79+
let v = match $v {
80+
Some(v) => Some(v.as_ref()),
81+
None => None,
82+
};
83+
query.bind(v)
84+
}};
8485
}
8586
query = match value {
8687
Value::Bool(v) => bind!(v, bool),

sea-query-driver/src/sqlx_sqlite.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ pub fn bind_params_sqlx_sqlite(input: TokenStream) -> TokenStream {
6969
};
7070
}
7171
macro_rules! bind_box {
72-
( $v: expr ) => {
73-
match $v {
74-
Some(v) => query.bind(v.as_ref()),
75-
None => query.bind(None::<bool>),
76-
}
77-
};
72+
( $v: expr ) => {{
73+
let v = match $v {
74+
Some(v) => Some(v.as_ref()),
75+
None => None,
76+
};
77+
query.bind(v)
78+
}};
7879
}
7980
query = match value {
8081
Value::Bool(v) => bind!(v, bool),

0 commit comments

Comments
 (0)