refactor: rename rows to records

This commit is contained in:
Ning Sun
2022-10-27 19:43:42 +08:00
parent 336ecada64
commit a2c0040ea5
2 changed files with 4 additions and 4 deletions

View File

@@ -136,7 +136,7 @@ impl TryFrom<Vec<RecordBatch>> for HttpRecordsOutput {
#[serde(rename_all = "lowercase")]
pub enum JsonOutput {
AffectedRows(usize),
Rows(HttpRecordsOutput),
Records(HttpRecordsOutput),
}
#[derive(Serialize, Debug, JsonSchema)]
@@ -173,14 +173,14 @@ impl JsonResponse {
}
Ok(Output::Stream(stream)) => match util::collect(stream).await {
Ok(rows) => match HttpRecordsOutput::try_from(rows) {
Ok(rows) => Self::with_output(Some(JsonOutput::Rows(rows))),
Ok(rows) => Self::with_output(Some(JsonOutput::Records(rows))),
Err(err) => Self::with_error(Some(format!(": {}", err))),
},
Err(e) => Self::with_error(Some(format!("Recordbatch error: {}", e))),
},
Ok(Output::RecordBatches(recordbatches)) => {
match HttpRecordsOutput::try_from(recordbatches.take()) {
Ok(rows) => Self::with_output(Some(JsonOutput::Rows(rows))),
Ok(rows) => Self::with_output(Some(JsonOutput::Records(rows))),
Err(err) => Self::with_error(Some(format!(": {}", err))),
}
}

View File

@@ -33,7 +33,7 @@ async fn test_sql_output_rows() {
assert!(json.success(), "{:?}", json);
assert!(json.error().is_none());
match json.output().expect("assertion failed") {
JsonOutput::Rows(records) => {
JsonOutput::Records(records) => {
assert_eq!(1, records.num_rows());
}
_ => unreachable!(),