set query limit

This commit is contained in:
OMGeeky
2023-04-12 16:57:17 +02:00
parent ced8bb5cb7
commit a68e80bfce
2 changed files with 16 additions and 0 deletions

View File

@@ -132,6 +132,13 @@ impl<'a, Table> BigQueryBuilder<'a, Table>
//region add content
pub fn set_limit(self, limit: usize) -> Self {
Self {
limit: Some(limit),
..self
}
}
fn set_select_fields(self, fields: Vec<String>) -> Result<Self> {
//TODO: this method probably does not work since the logic does
// not work if (at least the required) fields are not selected

View File

@@ -99,6 +99,15 @@ async fn simple_query() {
last_num = line.row_id;
}
}
#[tokio::test]
async fn test_select_limit_1() {
init_logger();
let client = get_test_client().await;
let q = DbInfos::query(&client)
.set_limit(1)
.run().await.unwrap();
assert_eq!(q.len(), 1);
}
fn init_logger() {
let _ = env_logger::builder()