--- trunk/lib/SQLSession/Action/DoSQL.pm 2006/12/03 00:10:31 11 +++ trunk/lib/SQLSession/Action/DoSQL.pm 2006/12/03 13:28:48 13 @@ -22,7 +22,8 @@ label is 'SQL', render as 'textarea', is mandatory, - ajax validates; + ajax validates, + ajax canonicalizes; param database => label is 'Database', @@ -60,6 +61,23 @@ } } +use SQL::ReservedWords; + +sub canonicalize_sql_query { + my $self = shift; + my $sql = shift; + + my @words = SQL::ReservedWords->words; + + my $w = join('|', @words); + + warn "canonicalize SQL: $sql"; + + $sql =~ s/\b($w)\b/uc($1)/egis; + + return $sql; +} + =head2 take_action Execute SQL query on database