Skip to content

Commit

Permalink
Select DISTINCT when not wantarray
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jan 17, 2018
1 parent 06fa9f3 commit baf41b1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/Geo/Coder/Free/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ sub fetchrow_hashref {

$self->_open() if(!$self->{table});

my $query = "SELECT DISTINCT * FROM $table";
my $query;
if(wantarray) {
$query = "SELECT * FROM $table";
} else {
$query = "SELECT DISTINCT * FROM $table";
}
my @args;
foreach my $c1(keys(%params)) {
if(scalar(@args) == 0) {
Expand Down Expand Up @@ -322,7 +327,12 @@ sub AUTOLOAD {

my %params = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_;

my $query = "SELECT DISTINCT $column FROM $table";
my $query;
if(wantarray) {
$query = "SELECT $column FROM $table";
} else {
$query = "SELECT DISTINCT $column FROM $table";
}
my @args;
foreach my $c1(keys(%params)) {
if(!defined($params{$c1})) {
Expand Down

0 comments on commit baf41b1

Please sign in to comment.