Repository navigation
fix(sqlite): preserve leading slash in database URLs #897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,7 +72,11 @@ impl ConnectionInfo { | |
| }, | ||
| password: url.password().map(|s| s.to_string()), | ||
| database: if url.path().len() > 1 { | ||
| Some(url.path().trim_start_matches('/').to_string()) | ||
| Some(if url.scheme() == "sqlite" { | ||
| url.path().to_string() | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the default config ( SQLite has no credentials to merge, so skipping the credential step for the |
||
| } else { | ||
| url.path().trim_start_matches('/').to_string() | ||
| }) | ||
| } else { | ||
| None | ||
| }, | ||
|
|
@@ -233,6 +237,7 @@ mod tests { | |
|
|
||
| assert_eq!(info.scheme, "sqlite"); | ||
| assert_eq!(info.database_type(), "sqlite"); | ||
| assert_eq!(info.database, Some("/path/to/db.sqlite".to_string())); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,3 +202,21 @@ async fn the_order_is_the_same_on_every_run() { | |
|
|
||
| connector.disconnect().await.unwrap(); | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn sqlite_absolute_url_opens_existing_database() { | ||
| let (_dir, db_path) = fixture(1).await; | ||
|
|
||
| let path = db_path.replace('\\', "/"); | ||
| let url = if cfg!(windows) { | ||
| format!("sqlite:///{}", path) | ||
| } else { | ||
| format!("sqlite://{}", path) | ||
| }; | ||
| let mut connector = connect(&url).await; | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| let columns = connector.profile_query("SELECT * FROM t").await.unwrap(); | ||
| assert_eq!(names(&columns), DECLARED_ORDER); | ||
|
|
||
| connector.disconnect().await.unwrap(); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
Fixes #839will close the issue, butsqlite://rel.sqlitestill fails withNo database path specified(CodeRabbit's note). Either cover it here or switch toPart of #839.