Bug 9045 - Adding some parameters to export_borrowers.pl
authorSophie Meynieux <sophie.meynieux@biblibre.com>
Mon, 18 Mar 2013 14:29:42 +0000 (15:29 +0100)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Thu, 21 Mar 2013 14:47:42 +0000 (10:47 -0400)
Followup : Adding test if results has some records and usage example for
--where clause

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
I infer from the bug comments that a proper test for this patch is to
check how the script reacts if it returns no results with a --where
clause, and to verify that there is a good usage example for the --where
option. These are both true, so I think this passes.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
All tests and QA script pass.

Tests done:
- tested -s option with \;
- tested -f surname -f borrowernumber to have multiple fields specified
- tested -w with "borrowernumber > 100" and similar with and without
  results - if no results a message is shown
- tested -h shows documentation for new options
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
misc/export_borrowers.pl

index e4fa7b0..7d3ce47 100755 (executable)
@@ -50,7 +50,10 @@ $0 -h
                             If no separator is specifield, a comma will be used.
     -H, --show-header       Print field names on first row
     -w, --where=CONDITION   Condition to filter borrowers to export
-                            (SQL where clause)
+                            (SQL where clause).
+                            CONDITION must be enclosed by double quotes and
+                            if needed, where value by single quotes.
+                            example : --where "surname='De Lattre'"
     -h, --help              Show this help
 
 USAGE
@@ -88,7 +91,7 @@ my $csv = Text::CSV->new( { sep_char => $separator, binary => 1 } );
 
 # If the user did not specify any field to export, we assume he wants them all
 # We retrieve the first borrower informations to get field names
-my ($borrowernumber) = $sth->fetchrow_array;
+my ($borrowernumber) = $sth->fetchrow_array or die "No borrower to export";
 my $member = GetMemberDetails($borrowernumber);
 @fields = keys %$member unless (@fields);