fix(query): omit spatial values for results without spatial columns

This commit is contained in:
t8y2 committed 2026-09-24 00:32:25 +08:00
1 parent 9868103119
commit 372d060d37
3 files changed
+16 -7

No files matched your search

+10 -5
View File
@@ -4776,11 +4776,12 @@ async fn execute_result_set_with_text_protocol_on_conn(
})
.collect();
let (spatial_columns, spatial_values) = spatial_columns.finish_with_values(spatial_values);
return Ok(MySqlQueryResult::exact(QueryResult {
columns,
column_types,
column_sortables: vec![],
spatial_columns: spatial_columns.finish(),
spatial_columns,
spatial_values,
rows: result_rows,
affected_rows: 0,
@@ -4868,12 +4869,13 @@ async fn execute_result_set_with_text_protocol_on_conn(
);
}
let (spatial_columns, spatial_values) = spatial_columns.finish_with_values(spatial_values);
Ok(MySqlQueryResult {
result: QueryResult {
columns,
column_types,
column_sortables: vec![],
spatial_columns: spatial_columns.finish(),
spatial_columns,
spatial_values,
rows: result_rows,
affected_rows: 0,
@@ -4997,12 +4999,13 @@ async fn execute_result_sets_with_text_protocol_on_conn(
Vec::new()
};
result_set_warnings.push(warnings);
let (spatial_columns, spatial_values) = spatial_columns.finish_with_values(spatial_values);
results.push(MySqlQueryResult {
result: QueryResult {
columns,
column_types,
column_sortables: vec![],
spatial_columns: spatial_columns.finish(),
spatial_columns,
spatial_values,
rows,
affected_rows: 0,
@@ -5206,12 +5209,13 @@ async fn execute_result_set_with_prepared_protocol_on_conn(
);
}
let (spatial_columns, spatial_values) = spatial_columns.finish_with_values(spatial_values);
Ok(MySqlQueryResult {
result: QueryResult {
columns,
column_types,
column_sortables: vec![],
spatial_columns: spatial_columns.finish(),
spatial_columns,
spatial_values,
rows: result_rows,
affected_rows: 0,
@@ -5564,11 +5568,12 @@ pub async fn execute_transaction_statement_on_conn(
// result set before reading the final status or allowing another
// operation on this physical connection.
query.drop_result().await.map_err(transaction_error_from_mysql_error)?;
let (spatial_columns, spatial_values) = spatial_columns.finish_with_values(spatial_values);
QueryResult {
columns,
column_types,
column_sortables: Vec::new(),
spatial_columns: spatial_columns.finish(),
spatial_columns,
spatial_values,
rows,
affected_rows: 0,
+2 -1
View File
@@ -820,11 +820,12 @@ async fn collect_first_result_limited(
restore_sqlserver_blank_column_names(&mut columns, sql);
restore_sqlserver_unsafe_column_types(&mut column_types, query);
let (spatial_columns, spatial_values) = spatial_values_builder.finish_with_values(spatial_values);
Ok(QueryResult {
columns,
column_types,
column_sortables: vec![],
spatial_columns: spatial_values_builder.finish(),
spatial_columns,
spatial_values,
rows,
affected_rows: 0,
+4 -1
View File
@@ -391,10 +391,13 @@ impl SpatialColumnBuilder {
}
}
pub fn finish(self) -> Vec<SpatialColumn> {
fn finish(self) -> Vec<SpatialColumn> {
self.columns.into_iter().map(|(column_index, srid)| SpatialColumn { column_index, srid }).collect()
}
/// Drivers collect one SRID slot per cell while streaming rows; a result
/// without spatial columns drops that all-`None` matrix instead of sending
/// it to every consumer.
pub fn finish_with_values(
self,
spatial_values: Vec<Vec<Option<u32>>>,