File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
internal/mithril-persistence/src/sqlite Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -70,20 +70,21 @@ impl WhereCondition {
70
70
71
71
/// Turn the condition into a SQL string representation.
72
72
pub fn expand ( self ) -> ( String , Vec < Value > ) {
73
- let mut expression = self . condition . expand ( ) ;
73
+ let expression = self . condition . expand ( ) ;
74
74
let parameters = self . parameters ;
75
- let mut param_index = 1 ;
76
75
//
77
76
// Replace parameters placeholders by numerated parameters.
78
- loop {
79
- if !expression. contains ( "?*" ) {
80
- break ;
81
- }
82
- expression = expression. replacen ( "?*" , & format ! ( "?{param_index}" ) , 1 ) ;
77
+ let mut final_expression = "" . to_string ( ) ;
78
+ let mut value = "" . to_string ( ) ;
79
+ let mut param_index = 0 ;
80
+ for sql_part in expression. split ( "?*" ) {
81
+ final_expression. push_str ( & value) ;
82
+ final_expression. push_str ( sql_part) ;
83
83
param_index += 1 ;
84
+ value = format ! ( "?{}" , param_index) ;
84
85
}
85
86
86
- ( expression , parameters)
87
+ ( final_expression . to_string ( ) , parameters)
87
88
}
88
89
89
90
/// Instanciate a condition with a `IN` statement.
You can’t perform that action at this time.
0 commit comments