optimize the SQL query for getting tax rates
This commit is contained in:
parent
d956e58bd7
commit
50fc494759
2 changed files with 6 additions and 14 deletions
|
|
@ -222,20 +222,12 @@ sub getTaxRates {
|
||||||
my $code = $address->get('code');
|
my $code = $address->get('code');
|
||||||
my $result = $self->session->db->buildArrayRef(
|
my $result = $self->session->db->buildArrayRef(
|
||||||
q{
|
q{
|
||||||
select taxRate from tax where
|
select taxRate from tax where country=?
|
||||||
(country=? and state='' and city='' and code='')
|
and (state='' or state=?)
|
||||||
OR (country=? and state=? and city='' and code='')
|
and (city='' or city=?)
|
||||||
OR (country=? and state=? and city=? and code='')
|
and (code='' or code=?)
|
||||||
OR (country=? and state=? and city='' and code=? )
|
|
||||||
OR (country=? and state=? and city=? and code=? )
|
|
||||||
},
|
},
|
||||||
[
|
[ $country, $state, $city, $code, ]);
|
||||||
$country,
|
|
||||||
$country, $state,
|
|
||||||
$country, $state, $city,
|
|
||||||
$country, $state, $code,
|
|
||||||
$country, $state, $city, $code,
|
|
||||||
]);
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -439,7 +439,7 @@ cmp_deeply(
|
||||||
|
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$taxer->getTaxRates($taxFreeAddress),
|
$taxer->getTaxRates($taxFreeAddress),
|
||||||
[0.0],
|
[0,0],
|
||||||
'getTaxRates: return correct data for a state with no tax data'
|
'getTaxRates: return correct data for a state with no tax data'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue