@@ -167,19 +167,31 @@ pub fn reference_action_sql(action: &ReferenceAction) -> &'static str {
167167
168168/// Convert a default value string to the appropriate backend-specific expression
169169pub fn convert_default_for_backend ( default : & str , backend : & DatabaseBackend ) -> String {
170- match default {
171- "gen_random_uuid()" | "UUID()" | "lower(hex(randomblob(16)))" => match backend {
170+ let lower = default. to_lowercase ( ) ;
171+
172+ // UUID generation functions
173+ if lower == "gen_random_uuid()" || lower == "uuid()" || lower == "lower(hex(randomblob(16)))" {
174+ return match backend {
172175 DatabaseBackend :: Postgres => "gen_random_uuid()" . to_string ( ) ,
173176 DatabaseBackend :: MySql => "(UUID())" . to_string ( ) ,
174177 DatabaseBackend :: Sqlite => "lower(hex(randomblob(16)))" . to_string ( ) ,
175- } ,
176- "current_timestamp()" | "now()" | "CURRENT_TIMESTAMP" => match backend {
178+ } ;
179+ }
180+
181+ // Timestamp functions (case-insensitive)
182+ if lower == "current_timestamp()"
183+ || lower == "now()"
184+ || lower == "current_timestamp"
185+ || lower == "getdate()"
186+ {
187+ return match backend {
177188 DatabaseBackend :: Postgres => "CURRENT_TIMESTAMP" . to_string ( ) ,
178189 DatabaseBackend :: MySql => "CURRENT_TIMESTAMP" . to_string ( ) ,
179190 DatabaseBackend :: Sqlite => "CURRENT_TIMESTAMP" . to_string ( ) ,
180- } ,
181- other => other. to_string ( ) ,
191+ } ;
182192 }
193+
194+ default. to_string ( )
183195}
184196
185197/// Check if the column type is an enum type
@@ -492,6 +504,9 @@ mod tests {
492504 #[ case:: now_postgres( "now()" , DatabaseBackend :: Postgres , "CURRENT_TIMESTAMP" ) ]
493505 #[ case:: now_mysql( "now()" , DatabaseBackend :: MySql , "CURRENT_TIMESTAMP" ) ]
494506 #[ case:: now_sqlite( "now()" , DatabaseBackend :: Sqlite , "CURRENT_TIMESTAMP" ) ]
507+ #[ case:: now_upper_postgres( "NOW()" , DatabaseBackend :: Postgres , "CURRENT_TIMESTAMP" ) ]
508+ #[ case:: now_upper_mysql( "NOW()" , DatabaseBackend :: MySql , "CURRENT_TIMESTAMP" ) ]
509+ #[ case:: now_upper_sqlite( "NOW()" , DatabaseBackend :: Sqlite , "CURRENT_TIMESTAMP" ) ]
495510 #[ case:: current_timestamp_upper_postgres(
496511 "CURRENT_TIMESTAMP" ,
497512 DatabaseBackend :: Postgres ,
0 commit comments