diff options
author | ivan <ivan> | 2006-08-25 19:30:52 +0000 |
---|---|---|
committer | ivan <ivan> | 2006-08-25 19:30:52 +0000 |
commit | 7517eaa583bcb213b62dfd0c11288aa50a350e8a (patch) | |
tree | a1a123dfb5a048348775e237f64ea25f6417bf2f /FS | |
parent | b19266599870172bda0921df60020f0440854750 (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.pm | 10 | ||||
-rw-r--r-- | FS/FS/Record.pm | 2 |
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; |