/[SQLSession]/trunk/lib/SQLSession/Action/DoSQL.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/SQLSession/Action/DoSQL.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 66 by dpavlin, Thu Jan 25 20:28:42 2007 UTC revision 82 by dpavlin, Mon Jan 29 21:43:06 2007 UTC
# Line 62  sub validate_sql_query { Line 62  sub validate_sql_query {
62          }          }
63  }  }
64    
 use SQL::ReservedWords;  
   
65  sub canonicalize_sql_query {  sub canonicalize_sql_query {
66          my $self = shift;          my $self = shift;
67          my $sql = shift;          my $sql = shift;
68    
69          my @words = SQL::ReservedWords->words;          warn "<<<< original SQL:\t$sql";
   
         my $w = join('|', @words);  
70    
71          $w .= '|limit|offset';  # fixup          sub sql_uc {
72                    my ($prefix,$sql,$suff) = @_;
73          warn "original SQL:\t$sql";                  return uc($sql).$suff if (! $prefix || $prefix eq '');
74                    return "\n" . uc($sql) . $suff;
75            }
76    
77          $sql =~ s/\b($w)\b/uc($1)/egis;          $sql =~ s/(\s*)(select|from|inner\s+join|order\s+by|where|group\s+by|having|limit|offset)(\s+)/sql_uc($1,$2,$3)/egis;
78    
79          warn "canonicalize SQL:\t$sql";          warn ">>>> canonicalize SQL:\n$sql";
80    
81          return $sql;          return $sql;
82  }  }

Legend:
Removed from v.66  
changed lines
  Added in v.82

  ViewVC Help
Powered by ViewVC 1.1.26