Extract basic metadata for non-cached queries
(&self, stmt: &Statement, query: &str)
| 242 | |
| 243 | /// Extract basic metadata for non-cached queries |
| 244 | fn extract_basic_metadata(&self, stmt: &Statement, query: &str) -> Result<StatementMetadata, rusqlite::Error> { |
| 245 | let columns = stmt.columns(); |
| 246 | let mut column_names = Vec::with_capacity(columns.len()); |
| 247 | let mut column_types = Vec::with_capacity(columns.len()); |
| 248 | |
| 249 | for column in columns { |
| 250 | let column_name = column.name().to_string(); |
| 251 | column_names.push(column_name.clone()); |
| 252 | |
| 253 | // Extract column type information from the column |
| 254 | let mut column_type = column.decl_type().map(|s| s.to_string()); |
| 255 | |
| 256 | // Special handling for PostgreSQL datetime functions |
| 257 | // If SQLite returns no type info but we know this is a datetime function, |
| 258 | // override with the correct PostgreSQL type |
| 259 | if column_type.is_none() && is_datetime_function_result(query, &column_name) { |
| 260 | column_type = Some("timestamptz".to_string()); |
| 261 | } |
| 262 | |
| 263 | column_types.push(column_type); |
| 264 | } |
| 265 | |
| 266 | let parameter_count = stmt.parameter_count(); |
| 267 | let is_select = query.trim().to_uppercase().starts_with("SELECT") || |
| 268 | query.trim().to_uppercase().starts_with("WITH"); |
| 269 | |
| 270 | Ok(StatementMetadata { |
| 271 | column_names, |
| 272 | column_types, |
| 273 | parameter_count, |
| 274 | is_select, |
| 275 | complexity: crate::query::QueryComplexity::Medium, |
| 276 | expected_result_size: crate::query::ResultSize::Unknown, |
| 277 | use_fast_path: false, |
| 278 | cache_results: false, |
| 279 | }) |
| 280 | } |
| 281 | |
| 282 | /// Get cached metadata if available |
| 283 | fn get_cached_metadata(&self, cache_key: &str) -> Option<StatementMetadata> { |
no test coverage detected