From e8b470ede42f2c91b6e2c28f309342c7b57f7cc8 Mon Sep 17 00:00:00 2001 From: Sophie Meynieux Date: Mon, 18 Mar 2013 15:29:42 +0100 Subject: [PATCH] Bug 9045 - Adding some parameters to export_borrowers.pl Followup : Adding test if results has some records and usage example for --where clause Signed-off-by: Owen Leonard 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 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 --- misc/export_borrowers.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/misc/export_borrowers.pl b/misc/export_borrowers.pl index e4fa7b0859..7d3ce47eed 100755 --- a/misc/export_borrowers.pl +++ b/misc/export_borrowers.pl @@ -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); -- 2.39.5