return records no matter what

This commit is contained in:
dal 2025-04-02 16:33:13 -06:00
parent 90a11bc175
commit 33eab20edb
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
1 changed files with 6 additions and 4 deletions

View File

@ -48,7 +48,7 @@ pub async fn validate_sql(
}; };
// Try to execute the query using query_engine // Try to execute the query using query_engine
let results = match query_engine(&data_source_id, sql, None).await { let results = match query_engine(&data_source_id, sql, Some(15)).await {
Ok(results) => results, Ok(results) => results,
Err(e) => return Err(anyhow!("SQL validation failed: {}", e)), Err(e) => return Err(anyhow!("SQL validation failed: {}", e)),
}; };
@ -58,15 +58,17 @@ pub async fn validate_sql(
// Create appropriate message based on number of records // Create appropriate message based on number of records
let message = if num_records == 0 { let message = if num_records == 0 {
"No records were found".to_string() "No records were found".to_string()
} else if num_records > 13 {
format!("{} records were returned (showing first 13)", num_records)
} else { } else {
format!("{} records were returned", num_records) format!("{} records were returned", num_records)
}; };
// Return records only if there are 13 or fewer // Return at most 13 records
let return_records = if num_records <= 13 { let return_records = if num_records <= 13 {
results results
} else { } else {
Vec::new() // Empty vec when more than 13 records results.into_iter().take(13).collect() // Take first 13 records when more than 13
}; };
Ok((message, return_records)) Ok((message, return_records))
@ -1060,7 +1062,7 @@ pub struct FileModificationBatch<T> {
pub modification_results: Vec<ModificationResult>, pub modification_results: Vec<ModificationResult>,
} }
#[derive(Debug, Serialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct ModificationResult { pub struct ModificationResult {
pub file_id: Uuid, pub file_id: Uuid,
pub file_name: String, pub file_name: String,