[ic] UI Combo Select Question

Mike Heins interchange-users@lists.akopia.com
Thu Jun 7 23:03:00 2001


Quoting Chris Rapier (rapier@psc.edu):
> I'm trying to use the combo select widget to allow admins to chose from
> 1 of several subcategories. Shoudl be pretty simple right? It looks up
> the column specified and returns all of the unique field values. 
> 
> Unfortunately, its not returning all of them. Its crapping out at 50.
> This is also happening under the image upload widget as well. If you
> have more than 50 images in that directory you'll only see the first 50.
> Which is kind of problematic.
> 
> My feeling is that this has something to do with a default value for
> mv_matchlimit which is, I think, 50. So I edited Scan.pm to raise this
> to 75 but I still only saw 50 items. I'm banging my head against a wall
> here. Any information on how I can increase this limit would be really
> really helpful.

Actually, you are running into a limit of 50 -- maybe I figured if you were
using DBM you would not want to do that type of thing for distinct value
sets, or maybe I just forgot that it would affect DBM. Remember, DB searches
for DBM can get very slow with large numbers of records.

These limits don't affect SQL databases.

The section of code that pertains is in lib/UI/Primitive.pm, and if you added
an option hash that set ml => 10000 it would work. Perhaps the better place
to set it is in lib/Vend/Table/Common.pm, and I will probably look at that
eventually for 4.7.x and higher.

For the moment, if you apply this patch to lib/UI/Primitive.pm (for 4.7, finding
4.6 equivalent is easy):

*** /DU/Primitive.pm	Tue May 29 10:22:33 2001
--- /du/Primitive.pm	Thu Jun  7 23:01:39 2001
***************
*** 920,927 ****
  				my $dbname = $record->{db} || $table;
  				my $db = Vend::Data::database_exists_ref($dbname);
  				last LOOK unless $db;
! 				my $query = "select DISTINCT $key, $fld FROM $dbname ORDER BY $fld";
! 				my $ary = $db->query($query);
  				last LOOK unless ref($ary);
  				if(! scalar @$ary) {
  					push @$ary, ["=--no current values--"];
--- 920,934 ----
  				my $dbname = $record->{db} || $table;
  				my $db = Vend::Data::database_exists_ref($dbname);
  				last LOOK unless $db;
! 				my $flds = $key eq $fld ? $key : "$key, $fld";
! 				my $query = "select DISTINCT $flds FROM $dbname ORDER BY $fld";
! 				my $ary = $db->query(
! 						{
! 							query => $query,
! 							ml => $::Variable->{UI_ACCESS_KEY_LIMIT} || 500,
! 							st => 'db',
! 						}
! 					);
  				last LOOK unless ref($ary);
  				if(! scalar @$ary) {
  					push @$ary, ["=--no current values--"];

it should help.

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

I don't want to get to the end of my life and find I have just
lived the length of it. I want to have lived the width of it as
well. -- Diane Ackerman