File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,12 @@ impl Config {
6565 Ok ( self )
6666 }
6767
68+ /// Metadata from DuckDB callers
69+ pub fn custom_user_agent ( mut self , custom_user_agent : & str ) -> Result < Config > {
70+ self . set ( "custom_user_agent" , custom_user_agent) ?;
71+ Ok ( self )
72+ }
73+
6874 /// The order type used when none is specified ([ASC] or DESC)
6975 pub fn default_order ( mut self , order : DefaultOrder ) -> Result < Config > {
7076 self . set ( "default_order" , & order. to_string ( ) ) ?;
@@ -190,6 +196,7 @@ mod test {
190196 . enable_object_cache ( false ) ?
191197 . enable_autoload_extension ( true ) ?
192198 . allow_unsigned_extensions ( ) ?
199+ . custom_user_agent ( "test_user_agent" ) ?
193200 . max_memory ( "2GB" ) ?
194201 . threads ( 4 ) ?
195202 . with ( "preserve_insertion_order" , "true" ) ?;
@@ -215,6 +222,10 @@ mod test {
215222 assert ! ( iter. next( ) . unwrap( ) . is_none( ) ) ;
216223 assert_eq ! ( iter. next( ) , None ) ;
217224
225+ let user_agent: Result < String > = db. query_row ( "PRAGMA USER_AGENT" , [ ] , |row| row. get ( 0 ) ) ;
226+ let user_agent = user_agent. unwrap ( ) ;
227+ assert ! ( & user_agent. ends_with( "rust test_user_agent" ) ) ;
228+
218229 Ok ( ( ) )
219230 }
220231
Original file line number Diff line number Diff line change @@ -298,6 +298,7 @@ impl Connection {
298298 }
299299
300300 let c_path = path_to_cstring ( path. as_ref ( ) ) ?;
301+ let config = config. with ( "duckdb_api" , "rust" ) . unwrap ( ) ;
301302 InnerConnection :: open_with_flags ( & c_path, config) . map ( |db| Connection {
302303 db : RefCell :: new ( db) ,
303304 cache : StatementCache :: with_capacity ( STATEMENT_CACHE_DEFAULT_CAPACITY ) ,
You can’t perform that action at this time.
0 commit comments