Run the entire test suite under replicated SQLite on DBICTEST_VIA_REPLICATED
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / SQLTracerObj.pm
index 23baeb3..5763639 100644 (file)
@@ -6,7 +6,16 @@ use warnings;
 
 use base 'DBIx::Class::Storage::Statistics';
 
-sub query_start { push @{$_[0]{sqlbinds}}, [ ($_[1] =~ /^\s*(\S+)/)[0], [ $_[1], @{ $_[2]||[] } ] ] }
+sub query_start {
+  my ($self, $sql, $bind) = @_;
+
+  my $op = ($sql =~ /^\s*(\S+)/)[0];
+
+  $sql =~ s/^ \s* \Q$op\E \s+ \[ .+? \]/$op/x
+    if $ENV{DBICTEST_VIA_REPLICATED};
+
+  push @{$self->{sqlbinds}}, [ $op, [ $sql, @{ $bind || [] } ] ];
+}
 
 # who the hell came up with this API >:(
 for my $txn (qw(begin rollback commit)) {