Skip to content
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

chore: add breaking test #127

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ serde_yaml = "0.9.33"
chrono = "0.4.38"
assert_cmd = "2"
tempfile = "3"
duckdb = "0.10.2"
52 changes: 50 additions & 2 deletions rust/quary-databases/src/databases_duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl DatabaseConnection for DuckDB {
.rows
.into_iter()
.map(|row| TableAddress {
name: row[0].clone(),
name: row[1].clone(),
full_path: format!("{}.{}", row[0].clone(), row[1].clone()),
})
.collect())
Expand All @@ -82,7 +82,7 @@ impl DatabaseConnection for DuckDB {
.rows
.into_iter()
.map(|row| TableAddress {
name: row[0].clone(),
name: row[1].clone(),
full_path: format!("{}.{}", row[0].clone(), row[1].clone()),
})
.collect())
Expand Down Expand Up @@ -1344,4 +1344,52 @@ snapshots:
.data_type
);
}

#[tokio::test]
async fn test_list_tables() {
let db = DuckDB::new_in_memory(Some("test_schema".to_string())).unwrap();
db.exec("CREATE TABLE test_schema.table1 (id INTEGER, name VARCHAR(255))")
.await
.unwrap();
db.exec("CREATE TABLE test_schema.table2 (id INTEGER, name VARCHAR(255))")
.await
.unwrap();

let tables = db.list_tables().await.unwrap();
assert_eq!(
tables,
vec![
TableAddress {
name: "table1".to_string(),
full_path: "test_schema.table1".to_string(),
},
TableAddress {
name: "table2".to_string(),
full_path: "test_schema.table2".to_string(),
},
]
);
}

#[tokio::test]
async fn test_list_views() {
let db = DuckDB::new_in_memory(Some("test_schema".to_string())).unwrap();
db.exec("CREATE TABLE test_schema.table1 (id INTEGER, name VARCHAR(255))")
.await
.unwrap();
db.exec("CREATE VIEW test_schema.view1 AS SELECT * FROM test_schema.table1")
.await
.unwrap();

let views = db.list_views().await.unwrap();
assert_eq!(
views,
vec![
TableAddress {
name: "view1".to_string(),
full_path: "test_schema.view1".to_string(),
},
]
);
}
}
Loading