Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e61e96

Browse files
committed
by_map method skip null value
1 parent37fe434 commit6e61e96

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

‎src/crud.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ macro_rules! impl_select {
185185
` where `
186186
trim ' and ': for key,item in condition:
187187
if item == null:
188-
continue;
188+
continue:
189189
if !item.is_array():
190190
` and ${key.operator_sql()}#{item}`
191191
if item.is_array():
@@ -280,7 +280,7 @@ macro_rules! impl_update {
280280
` where `
281281
trim ' and ': for key,item in condition:
282282
if item == null:
283-
continue;
283+
continue:
284284
if !item.is_array():
285285
` and ${key.operator_sql()}#{item}`
286286
if item.is_array():
@@ -383,7 +383,7 @@ macro_rules! impl_delete {
383383
` where `
384384
trim ' and ': for key,item in condition:
385385
if item == null:
386-
continue;
386+
continue:
387387
if !item.is_array():
388388
` and ${key.operator_sql()}#{item}`
389389
if item.is_array():

‎tests/crud_test.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,31 @@ mod test {
10321032
block_on(f);
10331033
}
10341034

1035+
#[test]
1036+
fntest_select_by_map_null_value(){
1037+
let f =asyncmove{
1038+
letmut rb =RBatis::new();
1039+
let queue =Arc::new(SyncVec::new());
1040+
rb.set_intercepts(vec![Arc::new(MockIntercept::new(queue.clone()))]);
1041+
rb.init(MockDriver{},"test").unwrap();
1042+
1043+
let ids:Vec<String> =vec![];
1044+
let r =MockTable::select_by_map(
1045+
&mut rb,
1046+
value!{
1047+
"id":"1",
1048+
"name":Option::<String>::None,
1049+
},
1050+
)
1051+
.await
1052+
.unwrap();
1053+
let(sql, args) = queue.pop().unwrap();
1054+
assert_eq!(sql,"select * from mock_table where id = ?");
1055+
assert_eq!(args, vec![value!("1")]);
1056+
};
1057+
block_on(f);
1058+
}
1059+
10351060
impl_select!(MockTable{select_from_table_name_by_id(id:&str,table_name:&str) =>"`where id = #{id}`"});
10361061

10371062
#[test]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp