File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -85,12 +85,16 @@ impl SqlBuilder {
8585 }
8686 }
8787
88- pub ( crate ) fn append ( & mut self , part : & str ) {
88+ pub ( crate ) fn append ( & mut self , suffix : & str ) {
8989 let Self :: InProgress ( parts) = self else {
9090 return ;
9191 } ;
9292
93- parts. push ( Part :: Text ( part. to_string ( ) ) ) ;
93+ if let Some ( Part :: Text ( text) ) = parts. last_mut ( ) {
94+ text. push_str ( suffix) ;
95+ } else {
96+ parts. push ( Part :: Text ( suffix. to_string ( ) ) ) ;
97+ }
9498 }
9599
96100 pub ( crate ) fn finish ( mut self ) -> Result < String > {
@@ -188,6 +192,12 @@ mod tests {
188192 ) ;
189193 }
190194
195+ #[ test]
196+ fn question_escape ( ) {
197+ let sql = SqlBuilder :: new ( "SELECT 1 FROM test WHERE a IN 'a??b'" ) ;
198+ assert_eq ! ( sql. finish( ) . unwrap( ) , r"SELECT 1 FROM test WHERE a IN 'a?b'" ) ;
199+ }
200+
191201 #[ test]
192202 fn option_as_null ( ) {
193203 let mut sql = SqlBuilder :: new ( "SELECT 1 FROM test WHERE a = ?" ) ;
You can’t perform that action at this time.
0 commit comments