@@ -5,6 +5,7 @@ use crate::{app_config::AppConfig, ON_CONNECT_FILE};
55use sqlx:: {
66 any:: { Any , AnyConnectOptions , AnyKind } ,
77 pool:: PoolOptions ,
8+ sqlite:: { Function , SqliteFunctionCtx } ,
89 ConnectOptions , Executor ,
910} ;
1011
@@ -128,6 +129,18 @@ fn set_custom_connect_options(options: &mut AnyConnectOptions, config: &AppConfi
128129 * sqlite_options = std:: mem:: take ( sqlite_options) . extension ( extension_name. clone ( ) ) ;
129130 }
130131 * sqlite_options = std:: mem:: take ( sqlite_options)
131- . collation ( "NOCASE" , |a, b| a. to_lowercase ( ) . cmp ( & b. to_lowercase ( ) ) ) ;
132+ . collation ( "NOCASE" , |a, b| a. to_lowercase ( ) . cmp ( & b. to_lowercase ( ) ) )
133+ . function ( Function :: new ( "upper" , |ctx : & SqliteFunctionCtx | match ctx
134+ . try_get_arg :: < String > ( 0 )
135+ {
136+ Ok ( s) => ctx. set_result ( s. to_uppercase ( ) ) ,
137+ Err ( e) => ctx. set_error ( & e. to_string ( ) ) ,
138+ } ) )
139+ . function ( Function :: new ( "lower" , |ctx : & SqliteFunctionCtx | match ctx
140+ . try_get_arg :: < String > ( 0 )
141+ {
142+ Ok ( s) => ctx. set_result ( s. to_lowercase ( ) ) ,
143+ Err ( e) => ctx. set_error ( & e. to_string ( ) ) ,
144+ } ) ) ;
132145 }
133146}
0 commit comments