summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2006-08-25 19:30:52 +0000
committerivan <ivan>2006-08-25 19:30:52 +0000
commit7517eaa583bcb213b62dfd0c11288aa50a350e8a (patch)
treea1a123dfb5a048348775e237f64ea25f6417bf2f /FS
parentb19266599870172bda0921df60020f0440854750 (diff)
use GROUP BY instead of DISTINCT ON in the state and country queries for better cross-database compatibility, based on a preliminary patch from Jason Thomas
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Misc.pm10
-rw-r--r--FS/FS/Record.pm2
2 files changed, 7 insertions, 5 deletions
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index 101a2d4e0..06fa51f54 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -359,10 +359,12 @@ sub states_hash {
# sort
map { s/[\n\r]//g; $_; }
map { $_->state; }
- qsearch( 'cust_main_county',
- { 'country' => $country },
- 'DISTINCT ON ( state ) *',
- )
+ qsearch({
+ 'select' => 'state',
+ 'table' => 'cust_main_county',
+ 'hashref' => { 'country' => $country },
+ 'extra_sql' => 'GROUP BY state',
+ })
;
#it could throw a fatal "Invalid country code" error (for example "AX")
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index a551bb8cc..cc7f551e9 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -388,7 +388,7 @@ sub qsearch {
my %result;
tie %result, "Tie::IxHash";
my @stuff = @{ $sth->fetchall_arrayref( {} ) };
- if($pkey) {
+ if ( $pkey && $stuff[0]->{$pkey} ) {
%result = map { $_->{$pkey}, $_ } @stuff;
} else {
@result{@stuff} = @stuff;