Helper function to detect if a column result is from a PostgreSQL datetime function
(query: &str, column_name: &str)
| 451 | |
| 452 | /// Helper function to detect if a column result is from a PostgreSQL datetime function |
| 453 | fn is_datetime_function_result(query: &str, column_name: &str) -> bool { |
| 454 | let query_upper = query.to_uppercase(); |
| 455 | let column_upper = column_name.to_uppercase(); |
| 456 | |
| 457 | // Check for NOW() function |
| 458 | if query_upper.contains("NOW()") && (column_upper == "NOW" || column_upper == "NOW()") { |
| 459 | return true; |
| 460 | } |
| 461 | |
| 462 | // Check for CURRENT_TIMESTAMP function |
| 463 | if query_upper.contains("CURRENT_TIMESTAMP") && (column_upper == "CURRENT_TIMESTAMP" || column_upper == "CURRENT_TIMESTAMP()") { |
| 464 | return true; |
| 465 | } |
| 466 | |
| 467 | // Check for aliased datetime functions like "SELECT NOW() as now" |
| 468 | if query_upper.contains("NOW()") && query_upper.contains(&format!("AS {column_upper}")) { |
| 469 | return true; |
| 470 | } |
| 471 | |
| 472 | if query_upper.contains("CURRENT_TIMESTAMP") && query_upper.contains(&format!("AS {column_upper}")) { |
| 473 | return true; |
| 474 | } |
| 475 | |
| 476 | false |
| 477 | } |
| 478 | |
| 479 | #[cfg(test)] |
| 480 | mod tests { |
no outgoing calls
no test coverage detected