The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
CHANGES 03
MANIFEST 04
META.yml 56
MYMETA.json 055
MYMETA.yml 030
inc/Module/Install/Base.pm 11
inc/Module/Install/Can.pm 679
inc/Module/Install/Fetch.pm 11
inc/Module/Install/GithubMeta.pm 47
inc/Module/Install/Makefile.pm 1215
inc/Module/Install/Metadata.pm 1118
inc/Module/Install/Win32.pm 11
inc/Module/Install/WriteAll.pm 11
inc/Module/Install.pm 33
lib/Test/DatabaseRow/Object.pm 047
lib/Test/DatabaseRow.pm 212
t/04sqlite.t 057
t/12verdata.t 0103
18 files changed (This is a version diff) 47443
@@ -1,3 +1,6 @@
+2.04  Add support to dump out the results from the database as
+      diagnosics with verbose_data / TEST_DBROW_VERBOSE_DATA
+
 2.03  Wrap qw() with () in foreach loops (thus avoiding deprecation
       warnings on 5.14.  (Thanks to Gabor Szabo for pull request)
 
@@ -15,10 +15,13 @@ lib/Test/DatabaseRow/Result.pm
 Makefile.PL
 MANIFEST			This list of files
 META.yml
+MYMETA.json
+MYMETA.yml
 t/01basic.t
 t/01tests.t
 t/02throws.t
 t/03tests.t
+t/04sqlite.t
 t/05warn.t
 t/06multiple.t
 t/07results.t
@@ -26,6 +29,7 @@ t/08utf8.t
 t/09has.t
 t/10result.t
 t/11th.t
+t/12verdata.t
 xt/001pod.t
 xt/002podcoverage.t
 xt/003perlcritic.t
@@ -3,12 +3,13 @@ abstract: 'simple database tests'
 author:
   - 'Written by Mark Fowler B<mark@twoshortplanks.com>'
 build_requires:
-  ExtUtils::MakeMaker: 6.42
+  ExtUtils::MakeMaker: 6.59
   Test::Builder::Tester: 0.09
 configure_requires:
-  ExtUtils::MakeMaker: 6.42
+  ExtUtils::MakeMaker: 6.59
 distribution_type: module
-generated_by: 'Module::Install version 1.00'
+dynamic_config: 1
+generated_by: 'Module::Install version 1.08'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -24,7 +25,7 @@ requires:
   Scalar::Util: 1.21
   perl: 5.6.0
 resources:
-  homepage: http://github.com/2shortplanks/Test-DatabaseRow/tree
+  homepage: https://github.com/2shortplanks/Test-DatabaseRow/tree
   license: http://dev.perl.org/licenses/
   repository: git://github.com/2shortplanks/Test-DatabaseRow.git
-version: 2.03
+version: '2.04'
@@ -0,0 +1,55 @@
+{
+   "abstract" : "simple database tests",
+   "author" : [
+      "Written by Mark Fowler B<mark@twoshortplanks.com>"
+   ],
+   "dynamic_config" : 0,
+   "generated_by" : "Module::Install version 1.08, CPAN::Meta::Converter version 2.140640",
+   "license" : [
+      "perl_5"
+   ],
+   "meta-spec" : {
+      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+      "version" : "2"
+   },
+   "name" : "Test-DatabaseRow",
+   "no_index" : {
+      "directory" : [
+         "inc",
+         "t",
+         "xt"
+      ]
+   },
+   "prereqs" : {
+      "build" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "6.59",
+            "Test::Builder::Tester" : "0.09"
+         }
+      },
+      "configure" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "6.59"
+         }
+      },
+      "runtime" : {
+         "requires" : {
+            "DBI" : "0",
+            "Scalar::Util" : "1.21",
+            "perl" : "5.006"
+         }
+      }
+   },
+   "release_status" : "stable",
+   "resources" : {
+      "homepage" : "https://github.com/2shortplanks/Test-DatabaseRow/tree",
+      "license" : [
+         "http://dev.perl.org/licenses/"
+      ],
+      "repository" : {
+         "type" : "git",
+         "url" : "git://github.com/2shortplanks/Test-DatabaseRow.git"
+      }
+   },
+   "version" : "2.03"
+}
@@ -0,0 +1,30 @@
+---
+abstract: 'simple database tests'
+author:
+  - 'Written by Mark Fowler B<mark@twoshortplanks.com>'
+build_requires:
+  ExtUtils::MakeMaker: '6.59'
+  Test::Builder::Tester: '0.09'
+configure_requires:
+  ExtUtils::MakeMaker: '6.59'
+dynamic_config: 0
+generated_by: 'Module::Install version 1.08, CPAN::Meta::Converter version 2.140640'
+license: perl
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: '1.4'
+name: Test-DatabaseRow
+no_index:
+  directory:
+    - inc
+    - t
+    - xt
+requires:
+  DBI: '0'
+  Scalar::Util: '1.21'
+  perl: '5.006'
+resources:
+  homepage: https://github.com/2shortplanks/Test-DatabaseRow/tree
+  license: http://dev.perl.org/licenses/
+  repository: git://github.com/2shortplanks/Test-DatabaseRow.git
+version: '2.03'
@@ -4,7 +4,7 @@ package Module::Install::Base;
 use strict 'vars';
 use vars qw{$VERSION};
 BEGIN {
-	$VERSION = '1.00';
+	$VERSION = '1.08';
 }
 
 # Suspend handler for "redefined" warnings
@@ -3,13 +3,12 @@ package Module::Install::Can;
 
 use strict;
 use Config                ();
-use File::Spec            ();
 use ExtUtils::MakeMaker   ();
 use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.00';
+	$VERSION = '1.08';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
@@ -29,7 +28,7 @@ sub can_use {
 	eval { require $mod; $pkg->VERSION($ver || 0); 1 };
 }
 
-# check if we can run some command
+# Check if we can run some command
 sub can_run {
 	my ($self, $cmd) = @_;
 
@@ -38,14 +37,88 @@ sub can_run {
 
 	for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
 		next if $dir eq '';
-		my $abs = File::Spec->catfile($dir, $_[1]);
+		require File::Spec;
+		my $abs = File::Spec->catfile($dir, $cmd);
 		return $abs if (-x $abs or $abs = MM->maybe_command($abs));
 	}
 
 	return;
 }
 
-# can we locate a (the) C compiler
+# Can our C compiler environment build XS files
+sub can_xs {
+	my $self = shift;
+
+	# Ensure we have the CBuilder module
+	$self->configure_requires( 'ExtUtils::CBuilder' => 0.27 );
+
+	# Do we have the configure_requires checker?
+	local $@;
+	eval "require ExtUtils::CBuilder;";
+	if ( $@ ) {
+		# They don't obey configure_requires, so it is
+		# someone old and delicate. Try to avoid hurting
+		# them by falling back to an older simpler test.
+		return $self->can_cc();
+	}
+
+	# Do we have a working C compiler
+	my $builder = ExtUtils::CBuilder->new(
+		quiet => 1,
+	);
+	unless ( $builder->have_compiler ) {
+		# No working C compiler
+		return 0;
+	}
+
+	# Write a C file representative of what XS becomes
+	require File::Temp;
+	my ( $FH, $tmpfile ) = File::Temp::tempfile(
+		"compilexs-XXXXX",
+		SUFFIX => '.c',
+	);
+	binmode $FH;
+	print $FH <<'END_C';
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+int main(int argc, char **argv) {
+    return 0;
+}
+
+int boot_sanexs() {
+    return 1;
+}
+
+END_C
+	close $FH;
+
+	# Can the C compiler access the same headers XS does
+	my @libs   = ();
+	my $object = undef;
+	eval {
+		local $^W = 0;
+		$object = $builder->compile(
+			source => $tmpfile,
+		);
+		@libs = $builder->link(
+			objects     => $object,
+			module_name => 'sanexs',
+		);
+	};
+	my $result = $@ ? 0 : 1;
+
+	# Clean up all the build files
+	foreach ( $tmpfile, $object, @libs ) {
+		next unless defined $_;
+		1 while unlink;
+	}
+
+	return $result;
+}
+
+# Can we locate a (the) C compiler
 sub can_cc {
 	my $self   = shift;
 	my @chunks = split(/ /, $Config::Config{cc}) or return;
@@ -78,4 +151,4 @@ if ( $^O eq 'cygwin' ) {
 
 __END__
 
-#line 156
+#line 236
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.00';
+	$VERSION = '1.08';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
@@ -7,18 +7,21 @@ use Cwd;
 use base qw(Module::Install::Base);
 use vars qw($VERSION);
 
-$VERSION = '0.10';
+$VERSION = '0.28';
 
 sub githubmeta {
   my $self = shift;
   return unless $Module::Install::AUTHOR;
   return unless _under_git();
   return unless $self->can_run('git');
-  return unless my ($git_url) = `git remote show -n origin` =~ /URL: (.*)$/m;
+  my $remote = shift || 'origin';
+  local $ENV{LC_ALL}='C';
+  local $ENV{LANG}='C';
+  return unless my ($git_url) = `git remote show -n $remote` =~ /URL: (.*)$/m;
   return unless $git_url =~ /github\.com/; # Not a Github repository
   my $http_url = $git_url;
   $git_url =~ s![\w\-]+\@([^:]+):!git://$1/!;
-  $http_url =~ s![\w\-]+\@([^:]+):!http://$1/!;
+  $http_url =~ s![\w\-]+\@([^:]+):!https://$1/!;
   $http_url =~ s!\.git$!/tree!;
   $self->repository( $git_url );
   $self->homepage( $http_url ) unless $self->homepage();
@@ -47,4 +50,4 @@ sub _under_git {
 'Github';
 __END__
 
-#line 108
+#line 113
@@ -8,7 +8,7 @@ use Fcntl qw/:flock :seek/;
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.00';
+	$VERSION = '1.08';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
@@ -215,18 +215,22 @@ sub write {
 	require ExtUtils::MakeMaker;
 
 	if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) {
-		# MakeMaker can complain about module versions that include
-		# an underscore, even though its own version may contain one!
-		# Hence the funny regexp to get rid of it.  See RT #35800
-		# for details.
-		my $v = $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/;
-		$self->build_requires(     'ExtUtils::MakeMaker' => $v );
-		$self->configure_requires( 'ExtUtils::MakeMaker' => $v );
+		# This previous attempted to inherit the version of
+		# ExtUtils::MakeMaker in use by the module author, but this
+		# was found to be untenable as some authors build releases
+		# using future dev versions of EU:MM that nobody else has.
+		# Instead, #toolchain suggests we use 6.59 which is the most
+		# stable version on CPAN at time of writing and is, to quote
+		# ribasushi, "not terminally fucked, > and tested enough".
+		# TODO: We will now need to maintain this over time to push
+		# the version up as new versions are released.
+		$self->build_requires(     'ExtUtils::MakeMaker' => 6.59 );
+		$self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 );
 	} else {
 		# Allow legacy-compatibility with 5.005 by depending on the
 		# most recent EU:MM that supported 5.005.
-		$self->build_requires(     'ExtUtils::MakeMaker' => 6.42 );
-		$self->configure_requires( 'ExtUtils::MakeMaker' => 6.42 );
+		$self->build_requires(     'ExtUtils::MakeMaker' => 6.36 );
+		$self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 );
 	}
 
 	# Generate the MakeMaker params
@@ -241,7 +245,6 @@ in a module, and provide its file path via 'version_from' (or
 'all_from' if you prefer) in Makefile.PL.
 EOT
 
-	$DB::single = 1;
 	if ( $self->tests ) {
 		my @tests = split ' ', $self->tests;
 		my %seen;
@@ -412,4 +415,4 @@ sub postamble {
 
 __END__
 
-#line 541
+#line 544
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.00';
+	$VERSION = '1.08';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
@@ -151,15 +151,21 @@ sub install_as_site   { $_[0]->installdirs('site')   }
 sub install_as_vendor { $_[0]->installdirs('vendor') }
 
 sub dynamic_config {
-	my $self = shift;
-	unless ( @_ ) {
-		warn "You MUST provide an explicit true/false value to dynamic_config\n";
-		return $self;
+	my $self  = shift;
+	my $value = @_ ? shift : 1;
+	if ( $self->{values}->{dynamic_config} ) {
+		# Once dynamic we never change to static, for safety
+		return 0;
 	}
-	$self->{values}->{dynamic_config} = $_[0] ? 1 : 0;
+	$self->{values}->{dynamic_config} = $value ? 1 : 0;
 	return 1;
 }
 
+# Convenience command
+sub static_config {
+	shift->dynamic_config(0);
+}
+
 sub perl_version {
 	my $self = shift;
 	return $self->{values}->{perl_version} unless @_;
@@ -170,7 +176,7 @@ sub perl_version {
 	# Normalize the version
 	$version = $self->_perl_version($version);
 
-	# We don't support the reall old versions
+	# We don't support the really old versions
 	unless ( $version >= 5.005 ) {
 		die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n";
 	}
@@ -515,6 +521,7 @@ sub __extract_license {
 		'GNU Free Documentation license'     => 'unrestricted', 1,
 		'GNU Affero General Public License'  => 'open_source',  1,
 		'(?:Free)?BSD license'               => 'bsd',          1,
+		'Artistic license 2\.0'              => 'artistic_2',   1,
 		'Artistic license'                   => 'artistic',     1,
 		'Apache (?:Software )?license'       => 'apache',       1,
 		'GPL'                                => 'gpl',          1,
@@ -550,9 +557,9 @@ sub license_from {
 
 sub _extract_bugtracker {
 	my @links   = $_[0] =~ m#L<(
-	 \Qhttp://rt.cpan.org/\E[^>]+|
-	 \Qhttp://github.com/\E[\w_]+/[\w_]+/issues|
-	 \Qhttp://code.google.com/p/\E[\w_\-]+/issues/list
+	 https?\Q://rt.cpan.org/\E[^>]+|
+	 https?\Q://github.com/\E[\w_]+/[\w_]+/issues|
+	 https?\Q://code.google.com/p/\E[\w_\-]+/issues/list
 	 )>#gx;
 	my %links;
 	@links{@links}=();
@@ -581,7 +588,7 @@ sub bugtracker_from {
 sub requires_from {
 	my $self     = shift;
 	my $content  = Module::Install::_readperl($_[0]);
-	my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg;
+	my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg;
 	while ( @requires ) {
 		my $module  = shift @requires;
 		my $version = shift @requires;
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.00';
+	$VERSION = '1.08';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '1.00';
+	$VERSION = '1.08';
 	@ISA     = qw{Module::Install::Base};
 	$ISCORE  = 1;
 }
@@ -31,7 +31,7 @@ BEGIN {
 	# This is not enforced yet, but will be some time in the next few
 	# releases once we can make sure it won't clash with custom
 	# Module::Install extensions.
-	$VERSION = '1.00';
+	$VERSION = '1.08';
 
 	# Storage for the pseudo-singleton
 	$MAIN    = undef;
@@ -451,7 +451,7 @@ sub _version ($) {
 }
 
 sub _cmp ($$) {
-	_version($_[0]) <=> _version($_[1]);
+	_version($_[1]) <=> _version($_[2]);
 }
 
 # Cloned from Params::Util::_CLASS
@@ -467,4 +467,4 @@ sub _CLASS ($) {
 
 1;
 
-# Copyright 2008 - 2010 Adam Kennedy.
+# Copyright 2008 - 2012 Adam Kennedy.
@@ -14,6 +14,7 @@ use Carp qw(croak);
 our @CARP_NOT = qw(Test::DatabaseRow::Object);
 
 use Test::DatabaseRow::Result;
+use Test::Builder;
 
 # okay, try loading Regexp::Common
 
@@ -25,6 +26,7 @@ use Test::DatabaseRow::Result;
 
 our %RE;
 unless (eval { require Regexp::Common; Regexp::Common->import; 1 }) {
+  ## no critic (ProhibitComplexRegexes)
   $RE{num}{real} = qr/
     (?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])
     (?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)
@@ -208,6 +210,27 @@ sub _build_db_results {
   return \@db_results;
 }
 
+# has db_results_dumped => ( is => "ro", lazy_build => 1 );
+sub db_results_dumped {
+  my $self = shift;
+  return $self->{db_results_dumped} ||= $self->_build_db_results_dumped;
+}
+sub has_db_results_dumped { my $self = shift; return exists $self->{db_results_dumped} }
+sub _build_db_results_dumped {
+  my $self = shift;
+
+  # get the results iff some was already fetched, otherwise we don't have any
+  my $results = $self->has_db_results ? $self->db_results : [];
+
+  my $builder = Test::Builder->new;
+  if ($builder->can("explain")) {
+    my ($str) = $builder->explain($results);
+    return $str;
+  }
+
+  croak "Cannot dump db results since the version of Test::Builder installed does not support 'explain'";
+}
+
 ## test related accessors ##############################################
 
 
@@ -290,6 +313,10 @@ sub has_min_results { my $self = shift; return exists $self->{min_results} }
 sub verbose { my $self = shift;return $self->{verbose} || 0 }
 sub has_verbose { my $self = shift; return exists $self->{verbose} }
 
+# has verbose_data => (is => 'ro', default => 0)
+sub verbose_data { my $self = shift;return $self->{verbose_data} || 0 }
+sub has_verbose_data { my $self = shift; return exists $self->{verbose_data} }
+
 ########################################################################
 # methods
 ########################################################################
@@ -430,6 +457,12 @@ sub _fail {
 
       # include the SQL diagnostics if we're verbose
       ($self->verbose ? $self->_sql_diag : ()),
+
+      # include a dumper of the results if we're verbose_data
+      ($self->verbose_data ?
+        ("Data returned from the database:",$self->db_results_dumped)
+        : ()
+      ),
     ],
   );
 }
@@ -580,6 +613,14 @@ If this accessor is not passed then it will be populated on
 first use by executing the contents of C<sql_and_bind> against the
 passed C<dbh>.
 
+=item db_results_dumped
+
+A string representation of the database results.
+
+If this accessor is not passed then it will be populated on
+first use by using Test::Builder's explain function on
+C<db_results>
+
 =item sql_and_bind
 
 The SQL and bind variables to execute if no results were passed
@@ -637,6 +678,12 @@ Truth value, default false.  Controls if the diagnostic messages
 printed during C<row_ok> on failure contain details of the SQL
 executed or not.
 
+=item verbose_data
+
+Truth value, default false.  Controls if the diagnostic messages
+printed during C<row_ok> on failure contain a Data::Dumper
+style dump of the resulting rows from the database.
+
 =item force_utf8
 
 Truth value, default false.  Controls if the utf8 flag should be
@@ -15,7 +15,7 @@ use Carp qw(croak);
 our @CARP_OK = qw(Test::DatabaseRow TestDatabaseRow::Object);
 
 # set the version number
-our $VERSION = "2.03";
+our $VERSION = "2.04";
 
 use Test::DatabaseRow::Object;
 our $object_class = "Test::DatabaseRow::Object";
@@ -30,12 +30,14 @@ sub row_ok {
   our $dbh;
   our $force_utf8;
   our $verbose;
+  our $verbose_data;
 
   # defaults
   my %args = (
     dbh => $dbh,
     force_utf8 => $force_utf8,
     verbose => $verbose || $ENV{TEST_DBROW_VERBOSE},
+    verbose_data => $verbose_data || $ENV{TEST_DBROW_VERBOSE_DATA},
     check_all_rows => 0,
   @_ );
 
@@ -307,9 +309,17 @@ against all rows returned from the database not just the first.
 
 Setting this option to a true value will cause verbose diagnostics to
 be printed out during any failing tests.  You may also enable this
-feature by setting either C<$Test::DatabaseRow::verbose> variable the
+feature by setting either C<$Test::DatabaseRow::verbose> variable or the
 C<TEST_DBROW_VERBOSE> environmental variable to a true value.
 
+=item verbose_data
+
+Setting this option to a true value will cause the results of running
+the SQL queries to be printed out during any failing tests.  You may
+also enable this feature by setting either
+C<$Test::DatabaseRow::verbose_data> variable or the
+C<TEST_DBROW_VERBOSE_DATA> environmental variable to a true value.
+
 =item store_rows
 
 Sometimes, it's not enough to just use the simple tests that
@@ -0,0 +1,57 @@
+#!/usr/bin/perl -w
+
+########################################################################
+# this tests with a "real" database if we have the DBD::SQLite
+# module installed
+########################################################################
+
+use strict;
+
+# check if we can use DBD::SQLite
+BEGIN {
+  unless (eval "use DBD::SQLite; 1") {
+    print "1..0 # Skipped: no DBD::SQLite\n";
+    exit;
+  }
+}
+
+use Test::More tests => 1;
+
+use Test::DatabaseRow;
+use DBI;
+use File::Temp qw(tempdir);
+
+my $dir = tempdir( CLEANUP => 1 );
+chdir($dir)
+  or die "Can't change directory to temp dir";
+END {
+  chdir('..');  # needed so deleting temp dir works on Windows
+}
+my $dbh = DBI->connect("dbi:SQLite:dbname=dbfile","","");
+
+$dbh->do(<<'SQL');
+CREATE TABLE perlmongers (
+  first_name STRING,
+  nick STRING
+);
+SQL
+
+my %data = (
+  "Andrew"  => "Zefram",
+  "Dagfinn" => "Ilmari",
+  "Mark"    => "Trelane",
+  "Leon"    => "acme",
+);
+
+$dbh->do(<<'SQL', {}, $_, $data{$_}) foreach keys %data;
+INSERT INTO perlmongers (first_name, nick) VALUES (?, ?)
+SQL
+
+row_ok(
+  dbh => $dbh,
+  tests => [ nick => "Trelane" ],
+  sql => [ <<'SQL', "Mark"]);
+    SELECT *
+      FROM perlmongers
+     WHERE first_name = ?
+SQL
@@ -0,0 +1,103 @@
+#!/usr/bin/perl
+
+########################################################################
+# this test checks that verbose_data works
+########################################################################
+
+use strict;
+use warnings;
+
+use Test::More;
+BEGIN {
+  if (Test::Builder->new->can("explain")) {
+    plan tests => 1;
+  } else {
+    plan skip_all => "Older version of Test::Builder without 'explain'"
+  }
+}
+
+use Test::DatabaseRow;
+use Test::Builder::Tester;
+
+use Data::Dumper;
+
+$Test::DatabaseRow::dbh = FakeDBI->new(results => 2);
+
+########################################################################
+
+my ($string) = explain([
+  {
+    'fooid' => 123,
+    'name' => 'fred'
+  },
+  {
+    'fooid' => 124,
+    'name' => 'bert'
+  }
+]);
+my @expected = split /\n/, $string;
+
+test_out("not ok 1 - matches");
+test_fail(+6);
+test_diag("While checking column 'name' on 1st row");
+test_diag("         got: 'fred'");
+test_diag("    expected: 'bar'");
+test_diag("Data returned from the database:");
+test_diag(@expected);
+row_ok(table   => "dummy",
+       where   => [ dummy => "dummy" ],
+       results => 2,
+       tests => [ "name" => "bar" ],
+       label   => "matches",
+       verbose_data => 1,
+);
+test_test("scalar");
+
+########################################################################
+# fake database package
+
+package FakeDBI;
+sub new { my $class = shift; return bless { @_ }, $class };
+sub quote { return "qtd<$_[1]>" };
+
+sub prepare
+{
+  my $this = shift;
+
+  # die if we need to
+  if ($this->fallover)
+    { die "Khaaaaaaaaaaaaan!" }
+
+  return FakeSTH->new($this);
+}
+
+sub results  { return $_[0]->{results}  }
+sub nomatch  { return $_[0]->{nomatch}  }
+sub fallover { return $_[0]->{fallover} }
+
+package FakeSTH;
+sub new { return bless { parent => $_[1] }, $_[0] };
+sub execute { return 1 };
+
+sub fetchrow_hashref
+{
+  my $this = shift;
+  my $parent = $this->{parent};
+
+  $this->{returned}++;
+
+  return if $parent->nomatch;
+  return if $this->{returned} > $parent->results;
+
+  if ($this->{returned} == 1)
+    { return { fooid => 123, name => "fred" } }
+
+  if ($this->{returned} == 2)
+    { return { fooid => 124, name => "bert" } }
+
+  if ($this->{returned} == 3)
+    { return { fooid => 125, name => "ernie" } }
+
+  # oops, someone wanted more results than we prepared
+  return;
+}