[Rt-commit] r3926 - in rt/branches/3.5-TESTING: . etc html lib lib/t/regression

jesse at bestpractical.com jesse at bestpractical.com
Wed Oct 5 15:23:51 EDT 2005


Author: jesse
Date: Wed Oct  5 15:23:50 2005
New Revision: 3926

Modified:
   rt/branches/3.5-TESTING/   (props changed)
   rt/branches/3.5-TESTING/etc/RT_Config.pm.in
   rt/branches/3.5-TESTING/html/autohandler
   rt/branches/3.5-TESTING/lib/RT.pm.in
   rt/branches/3.5-TESTING/lib/t/regression/20-sort-by-requestor.t
Log:
 r17084 at hualien:  jesse | 2005-10-05 11:08:50 -0400
  r17067 at hualien:  jesse | 2005-10-05 10:39:13 -0400
   r17053 at hualien:  jesse | 2005-10-05 10:00:45 -0400
    r15946 at hualien (orig r3872):  alexmv | 2005-09-22 12:38:17 -0400
     r6181 at zoq-fot-pik:  chmrr | 2005-09-02 12:09:41 -0400
      * Additional tests for no requestor (should still sort correctly)
    
    r15947 at hualien (orig r3873):  alexmv | 2005-09-22 12:38:34 -0400
     r6451 at zoq-fot-pik:  chmrr | 2005-09-22 12:37:30 -0400
      * Statement logging
    
    r17047 at hualien (orig r3903):  alexmv | 2005-10-03 15:57:38 -0400
     r6572 at zoq-fot-pik:  chmrr | 2005-10-03 15:47:52 -0400
      * Make test text reflect the number of tickets the test is looking for
    
    r17048 at hualien (orig r3904):  alexmv | 2005-10-03 15:57:45 -0400
    
   
  
 


Modified: rt/branches/3.5-TESTING/etc/RT_Config.pm.in
==============================================================================
--- rt/branches/3.5-TESTING/etc/RT_Config.pm.in	(original)
+++ rt/branches/3.5-TESTING/etc/RT_Config.pm.in	Wed Oct  5 15:23:50 2005
@@ -282,6 +282,11 @@
 
 @LogToSyslogConf = () unless (@LogToSyslogConf);
 
+# RT has rudimentary SQL statement logging support if you have
+# DBIx-SearchBuilder 1.31_1 or higher; simply set $StatementLog to be
+# the level that you wish SQL statements to be logged at.
+Set($StatementLog, undef);
+
 # }}}
 
 # {{{ Web interface configuration

Modified: rt/branches/3.5-TESTING/html/autohandler
==============================================================================
--- rt/branches/3.5-TESTING/html/autohandler	(original)
+++ rt/branches/3.5-TESTING/html/autohandler	Wed Oct  5 15:23:50 2005
@@ -49,6 +49,11 @@
 $RT::Handle->ForceRollback() if $RT::Handle->TransactionDepth;
 
 
+if ($RT::StatementLog) {
+    $RT::Handle->ClearSQLStatementLog;
+    $RT::Handle->LogSQLStatements(1);
+}
+
 local *session unless $m->is_subrequest; # avoid reentrancy, as suggested by masonbook
 
 # Disable AutoFlush using an attribute
@@ -253,6 +258,25 @@
     $m->comp('/Elements/Login', %ARGS);
     $m->abort();
 }
+
+if ($RT::StatementLog) {
+    my @log = $RT::Handle->SQLStatementLog;
+    $RT::Handle->ClearSQLStatementLog;
+    for my $stmt (@log) {
+        my ($time, $sql, $bind, $duration) = @{$stmt};
+        my @bind;
+        if (ref $bind) {
+            @bind = @{$bind};
+        } else {
+            # Older DBIx-SB
+            $duration = $bind;
+        }
+        $RT::Logger->log( level => $RT::StatementLog,
+                          message => "SQL(".sprintf("%.2f",$duration)."s): $sql;" . (@bind ? "  [ bound values: @{[map{qq|'$_'|} @bind]} ]" : "")
+                        );
+    }
+}
+
 </%INIT>
 <& /Elements/Footer, %ARGS &>
 <%ARGS>

Modified: rt/branches/3.5-TESTING/lib/RT.pm.in
==============================================================================
--- rt/branches/3.5-TESTING/lib/RT.pm.in	(original)
+++ rt/branches/3.5-TESTING/lib/RT.pm.in	Wed Oct  5 15:23:50 2005
@@ -161,7 +161,7 @@
     InitLogging(); 
 }
 
-  
+
 =head2 ConnectToDatabase
 
 Get a database connection
@@ -175,7 +175,7 @@
     } 
     $Handle->Connect();
 }
-    
+
 =head2 InitLogging
 
 Create the RT::Logger object. 

Modified: rt/branches/3.5-TESTING/lib/t/regression/20-sort-by-requestor.t
==============================================================================
--- rt/branches/3.5-TESTING/lib/t/regression/20-sort-by-requestor.t	(original)
+++ rt/branches/3.5-TESTING/lib/t/regression/20-sort-by-requestor.t	Wed Oct  5 15:23:50 2005
@@ -11,9 +11,10 @@
 my $queue = 'SearchTests-'.rand(200);
 $q->Create(Name => $queue);
 
-my @requestors = ( ('bravo at example.com') x 5, ('alpha at example.com') x 5,
-                   ('delta at example.com') x 5, ('charlie at example.com') x 5);
-my @subjects = ("first test", "second test", "third test", "fourth test") x 5;
+my @requestors = ( ('bravo at example.com') x 6, ('alpha at example.com') x 6,
+                   ('delta at example.com') x 6, ('charlie at example.com') x 6,
+                   (undef) x 6);
+my @subjects = ("first test", "second test", "third test", "fourth test", "fifth test") x 6;
 while (@requestors) {
     my $t = RT::Ticket->new($RT::SystemUser);
     my ( $id, undef $msg ) = $t->Create(
@@ -27,7 +28,7 @@
 {
     my $tix = RT::Tickets->new($RT::SystemUser);
     $tix->FromSQL("Queue = '$queue'");
-    is($tix->Count, 20, "found twenty tickets");
+    is($tix->Count, 30, "found thirty tickets");
 }
 
 {
@@ -36,7 +37,7 @@
     $tix->OrderByCols({ FIELD => "Subject" });
     my @subjects;
     while (my $t = $tix->Next) { push @subjects, $t->Subject; }
-    is(@subjects, 5, "found five tickets");
+    is(@subjects, 6, "found six tickets");
     is_deeply( \@subjects, [ sort @subjects ], "Subjects are sorted");
 }
 
@@ -48,6 +49,7 @@
     while (my $t = $tix->Next) { push @mails, $t->RequestorAddresses; }
     is(@mails, 5, "found five tickets");
     is_deeply( \@mails, [ sort @mails ], "Addresses are sorted");
+    print STDERR "Emails are ", join(" ", map {defined $_ ? $_ : "undef"} @mails);
 }
 
 {
@@ -56,8 +58,9 @@
     $tix->OrderByCols({ FIELD => "Requestor.EmailAddress" });
     my @mails;
     while (my $t = $tix->Next) { push @mails, $t->RequestorAddresses; }
-    is(@mails, 5, "found five tickets");
+    is(@mails, 6, "found six tickets");
     is_deeply( \@mails, [ sort @mails ], "Addresses are sorted");
+    print STDERR "Emails are ", join(" ", map {defined $_ ? $_ : "undef"} @mails);
 }
 
 # vim:ft=perl:


More information about the Rt-commit mailing list