mirror of
https://github.com/OMGeeky/google_bigquery_v2.git
synced 2025-12-30 08:23:32 +01:00
set query limit
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user