File tree Expand file tree Collapse file tree
diesel/src/sqlite/connection Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ pub struct RawConnection {
1818impl RawConnection {
1919 pub fn establish ( database_url : & str ) -> ConnectionResult < Self > {
2020 let mut conn_pointer = ptr:: null_mut ( ) ;
21- let database_url = CString :: new ( database_url) ?;
21+ let database_url = CString :: new ( database_url. trim_start_matches ( "sqlite://" ) ) ?;
2222 let connection_status =
2323 unsafe { ffi:: sqlite3_open ( database_url. as_ptr ( ) , & mut conn_pointer) } ;
2424
Original file line number Diff line number Diff line change @@ -73,3 +73,11 @@ fn managing_updated_at_for_table() {
7373 let new_time: NaiveDateTime = query. first ( & connection) . unwrap ( ) ;
7474 assert ! ( old_time < new_time) ;
7575}
76+
77+ #[ test]
78+ #[ cfg( feature = "sqlite" ) ]
79+ fn strips_sqlite_url_prefix ( ) {
80+ let mut path = std:: env:: temp_dir ( ) ;
81+ path. push ( "diesel_test_sqlite.db" ) ;
82+ assert ! ( SqliteConnection :: establish( & format!( "sqlite://{}" , path. display( ) ) ) . is_ok( ) ) ;
83+ }
You can’t perform that action at this time.
0 commit comments