re-format SQL in textarea
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 7 Apr 2011 19:55:18 +0000 (19:55 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 7 Apr 2011 19:55:18 +0000 (19:55 +0000)
web_ui.pl

index 930fa47..eb08d1d 100755 (executable)
--- a/web_ui.pl
+++ b/web_ui.pl
@@ -81,6 +81,10 @@ get '/gnuplot' => sub {
        my $sql = $self->param('sql');
        return $self->render('gnuplot', img => '', gnuplot => '') unless $sql;
 
+       # re-format SQL
+       $sql =~ s/(from|where|order|limit|join)/\n$1/gs;
+       $self->param( sql => $sql );
+
        my $ret = $gearman->req( 'SUBMIT_JOB', 'Store_sql', '', $sql );
        die "no result for $sql" unless $ret;