optimize the SQL query for getting tax rates

This commit is contained in:
Colin Kuskie 2008-03-06 23:41:16 +00:00
parent d956e58bd7
commit 50fc494759
2 changed files with 6 additions and 14 deletions

View file

@ -222,20 +222,12 @@ sub getTaxRates {
my $code = $address->get('code');
my $result = $self->session->db->buildArrayRef(
q{
select taxRate from tax where
(country=? and state='' and city='' and code='')
OR (country=? and state=? and city='' and code='')
OR (country=? and state=? and city=? and code='')
OR (country=? and state=? and city='' and code=? )
OR (country=? and state=? and city=? and code=? )
select taxRate from tax where country=?
and (state='' or state=?)
and (city='' or city=?)
and (code='' or code=?)
},
[
$country,
$country, $state,
$country, $state, $city,
$country, $state, $code,
$country, $state, $city, $code,
]);
[ $country, $state, $city, $code, ]);
return $result;
}

View file

@ -439,7 +439,7 @@ cmp_deeply(
cmp_deeply(
$taxer->getTaxRates($taxFreeAddress),
[0.0],
[0,0],
'getTaxRates: return correct data for a state with no tax data'
);