MCPcopy Create free account
hub / github.com/erans/pgsqlite / is_datetime_function_result

Function is_datetime_function_result

src/cache/enhanced_statement_pool.rs:453–477  ·  view source on GitHub ↗

Helper function to detect if a column result is from a PostgreSQL datetime function

(query: &str, column_name: &str)

Source from the content-addressed store, hash-verified

451
452/// Helper function to detect if a column result is from a PostgreSQL datetime function
453fn 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)]
480mod tests {

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected