File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,12 @@ impl Config {
65
65
Ok ( self )
66
66
}
67
67
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
+
68
74
/// The order type used when none is specified ([ASC] or DESC)
69
75
pub fn default_order ( mut self , order : DefaultOrder ) -> Result < Config > {
70
76
self . set ( "default_order" , & order. to_string ( ) ) ?;
@@ -190,6 +196,7 @@ mod test {
190
196
. enable_object_cache ( false ) ?
191
197
. enable_autoload_extension ( true ) ?
192
198
. allow_unsigned_extensions ( ) ?
199
+ . custom_user_agent ( "test_user_agent" ) ?
193
200
. max_memory ( "2GB" ) ?
194
201
. threads ( 4 ) ?
195
202
. with ( "preserve_insertion_order" , "true" ) ?;
@@ -215,6 +222,10 @@ mod test {
215
222
assert ! ( iter. next( ) . unwrap( ) . is_none( ) ) ;
216
223
assert_eq ! ( iter. next( ) , None ) ;
217
224
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
+
218
229
Ok ( ( ) )
219
230
}
220
231
Original file line number Diff line number Diff line change @@ -298,6 +298,7 @@ impl Connection {
298
298
}
299
299
300
300
let c_path = path_to_cstring ( path. as_ref ( ) ) ?;
301
+ let config = config. with ( "duckdb_api" , "rust" ) . unwrap ( ) ;
301
302
InnerConnection :: open_with_flags ( & c_path, config) . map ( |db| Connection {
302
303
db : RefCell :: new ( db) ,
303
304
cache : StatementCache :: with_capacity ( STATEMENT_CACHE_DEFAULT_CAPACITY ) ,
You can’t perform that action at this time.
0 commit comments