Skip to content

Commit

Permalink
Fix WHERE in autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Dec 6, 2019
1 parent 471d9fc commit f5ce530
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Geo/Coder/Free/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -543,26 +543,30 @@ sub AUTOLOAD {
my %params = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_;

my $query;
my $done_where = 0;
if(wantarray && !delete($params{'distinct'})) {
if(($self->{'type'} eq 'CSV') && !$self->{no_entry}) {
$query = "SELECT $column FROM $table WHERE entry IS NOT NULL AND entry NOT LIKE '#%'";
$done_where = 1;
} else {
$query = "SELECT $column FROM $table";
}
} else {
if(($self->{'type'} eq 'CSV') && !$self->{no_entry}) {
$query = "SELECT DISTINCT $column FROM $table WHERE entry IS NOT NULL AND entry NOT LIKE '#%'";
$done_where = 1;
} else {
$query = "SELECT DISTINCT $column FROM $table";
}
}
my @args;
while(my ($key, $value) = each %params) {
if(defined($value)) {
if(scalar(@args) || ($self->{'type'} eq 'CSV')) {
if($done_where) {
$query .= " AND $key = ?";
} else {
$query .= " WHERE $key = ?";
$done_where = 1;
}
push @args, $value;
} else {
Expand Down

0 comments on commit f5ce530

Please sign in to comment.