ensure _order_by_chunks returns what it used to
[dbsrgits/SQL-Abstract.git] / maint / lib / Chunkstrumenter.pm
diff --git a/maint/lib/Chunkstrumenter.pm b/maint/lib/Chunkstrumenter.pm
new file mode 100644 (file)
index 0000000..e97c18b
--- /dev/null
@@ -0,0 +1,23 @@
+package Chunkstrumenter;
+
+use strictures 2;
+use Class::Method::Modifiers qw(install_modifier);
+use Data::Dumper::Concise;
+use Context::Preserve;
+
+require SQL::Abstract;
+
+open my $log_fh, '>>', 'chunkstrumenter.log';
+
+install_modifier 'SQL::Abstract', around => '_order_by_chunks' => sub {
+  my ($orig, $self) = (shift, shift);
+  my @args = @_;
+  preserve_context { $self->$orig(@args) }
+    after => sub {
+      my $dumped = Dumper([ $self->{quote_char}, \@args, \@_ ]);
+      $dumped =~ s/\n\Z/,\n/;
+      print $log_fh $dumped;
+    };
+};
+
+1;