@@ -214,17 +214,20 @@ macro_rules! impl_select {
214
214
"` where ${column} in (`
215
215
trim ',': for _,item in column_values:
216
216
#{item},
217
- `)`" } , $table_name) ;
217
+ `)`" } , $table_name => { if column_values . is_empty ( ) { return Ok ( vec! [ ] ) ; } } ) ;
218
218
} ;
219
219
( $table: ty{ $fn_name: ident $( < $( $gkey: ident: $gtype: path $( , ) ?) * >) ? ( $( $param_key: ident: $param_type: ty $( , ) ?) * ) => $sql: expr} $( , $table_name: expr) ?) => {
220
220
$crate:: impl_select!( $table{ $fn_name$( <$( $gkey: $gtype, ) * >) ?( $( $param_key: $param_type, ) * ) ->Vec => $sql} $( , $table_name) ?) ;
221
221
} ;
222
- ( $table: ty{ $fn_name: ident $( < $( $gkey: ident: $gtype: path $( , ) ?) * >) ? ( $( $param_key: ident: $param_type: ty $( , ) ?) * ) -> $container: tt => $sql: expr} $( , $table_name: expr) ?) => {
222
+ ( $table: ty{ $fn_name: ident $( < $( $gkey: ident: $gtype: path $( , ) ?) * >) ? ( $( $param_key: ident: $param_type: ty $( , ) ?) * ) -> $container: tt => $sql: expr} $( , $table_name: expr) ? $ ( => $cond : expr ) ? ) => {
223
223
impl $table{
224
224
pub async fn $fn_name $( <$( $gkey: $gtype, ) * >) ? ( executor: & dyn $crate:: executor:: Executor , $( $param_key: $param_type, ) * ) -> std:: result:: Result <$container<$table>, $crate:: rbdc:: Error >
225
225
{
226
226
#[ $crate:: py_sql( "`select ${table_column} from ${table_name} `" , $sql) ]
227
227
async fn $fn_name$( <$( $gkey: $gtype, ) * >) ?( executor: & dyn $crate:: executor:: Executor , table_column: & str , table_name: & str , $( $param_key: $param_type, ) * ) -> std:: result:: Result <$container<$table>, $crate:: rbdc:: Error > { impled!( ) }
228
+
229
+ $( $cond) ?
230
+
228
231
let mut table_column = "*" . to_string( ) ;
229
232
let mut table_name = String :: new( ) ;
230
233
$( table_name = $table_name. to_string( ) ; ) ?
@@ -398,7 +401,7 @@ macro_rules! impl_delete {
398
401
"`where ${column} in (`
399
402
trim ',': for _,item in column_values:
400
403
#{item},
401
- `)`" } , $table_name) ;
404
+ `)`" } , $table_name => { if column_values . is_empty ( ) { return Ok ( $crate :: rbdc :: db :: ExecResult :: default ( ) ) ; } } ) ;
402
405
403
406
impl $table {
404
407
pub async fn delete_by_column_batch<V : serde:: Serialize >(
@@ -419,7 +422,7 @@ macro_rules! impl_delete {
419
422
}
420
423
}
421
424
} ;
422
- ( $table: ty{ $fn_name: ident $( < $( $gkey: ident: $gtype: path $( , ) ?) * >) ? ( $( $param_key: ident: $param_type: ty$( , ) ?) * ) => $sql_where: expr} $( , $table_name: expr) ?) => {
425
+ ( $table: ty{ $fn_name: ident $( < $( $gkey: ident: $gtype: path $( , ) ?) * >) ? ( $( $param_key: ident: $param_type: ty$( , ) ?) * ) => $sql_where: expr} $( , $table_name: expr) ? $ ( => $cond : expr ) ? ) => {
423
426
impl $table {
424
427
pub async fn $fn_name$( <$( $gkey: $gtype, ) * >) ?(
425
428
executor: & dyn $crate:: executor:: Executor ,
@@ -436,6 +439,7 @@ macro_rules! impl_delete {
436
439
) -> std:: result:: Result <$crate:: rbdc:: db:: ExecResult , $crate:: rbdc:: Error > {
437
440
impled!( )
438
441
}
442
+ $( $cond) ?
439
443
let mut table_name = String :: new( ) ;
440
444
$( table_name = $table_name. to_string( ) ; ) ?
441
445
#[ $crate:: snake_name( $table) ]
0 commit comments