[interchange-cvs] interchange - heins modified 2 files

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Thu Oct 18 00:17:00 2001


User:      heins
Date:      2001-10-18 04:16:16 GMT
Modified:  lib/Vend/Table Common.pm DBI.pm
Log:
	* Add syntactic sugar to set_slice, where you can just
	  pass a hash reference with key/value instead of two
	  array refs. You can still do the two array-ref thing
	  for speed if you want.

	* Add NO_ASCII_INDEX option (which we might consider making
	  default for non-DBM tables). Those .1 .2 and symlink files
	  are cluttering up the directory and are useless for DBI.
	  In fact, they are pretty useless for DBM these days unless
	  you have 100,000 items and know enough to use dl=category
	  for category searches.... 8-)

Revision  Changes    Path
2.2       +10 -1     interchange/lib/Vend/Table/Common.pm


rev 2.2, prev_rev 2.1
Index: Common.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Table/Common.pm,v
retrieving revision 2.1
retrieving revision 2.2
diff -u -r2.1 -r2.2
--- Common.pm	2001/10/06 06:22:12	2.1
+++ Common.pm	2001/10/18 04:16:16	2.2
@@ -1,6 +1,6 @@
 # Vend::Table::Common - Common access methods for Interchange databases
 #
-# $Id: Common.pm,v 2.1 2001/10/06 06:22:12 mheins Exp $
+# $Id: Common.pm,v 2.2 2001/10/18 04:16:16 mheins Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -22,7 +22,7 @@
 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA  02111-1307  USA.
 
-$VERSION = substr(q$Revision: 2.1 $, 10);
+$VERSION = substr(q$Revision: 2.2 $, 10);
 use strict;
 
 package Vend::Table::Common;
@@ -322,6 +322,15 @@
 		return undef;
 	}
 
+	if(ref $fary ne 'ARRAY') {
+		my $href = $fary;
+		if(ref $href ne 'HASH') {
+			$href = { $fary, $vary, @_ }
+		}
+		$vary = [ values %$href ];
+		$fary = [ keys   %$href ];
+	}
+
 	my $keyname = $s->[$CONFIG]{KEY};
 
 	my ($found_key) = grep $_ eq $keyname, @$fary;
@@ -978,7 +987,7 @@
 	my @i;  # Array of field names for sort
 	my @o;  # Array of sort options
 	my %comma;
-	if($options->{INDEX}) {
+	if($options->{INDEX} and ! $options->{NO_ASCII_INDEX}) {
 		my @f; my $f;
 		my @n;
 		my $i;



2.1       +12 -3     interchange/lib/Vend/Table/DBI.pm


rev 2.1, prev_rev 2.0
Index: DBI.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Table/DBI.pm,v
retrieving revision 2.0
retrieving revision 2.1
diff -u -r2.0 -r2.1
--- DBI.pm	2001/07/18 02:23:20	2.0
+++ DBI.pm	2001/10/18 04:16:16	2.1
@@ -1,6 +1,6 @@
 # Vend::Table::DBI - Access a table stored in an DBI/DBD database
 #
-# $Id: DBI.pm,v 2.0 2001/07/18 02:23:20 jon Exp $
+# $Id: DBI.pm,v 2.1 2001/10/18 04:16:16 mheins Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -20,7 +20,7 @@
 # MA  02111-1307  USA.
 
 package Vend::Table::DBI;
-$VERSION = substr(q$Revision: 2.0 $, 10);
+$VERSION = substr(q$Revision: 2.1 $, 10);
 
 use strict;
 
@@ -912,6 +912,15 @@
 	$tkey = $s->quote($key, $s->[$KEY]) if defined $key;
 #::logDebug("tkey now $tkey");
 
+	if(ref $fary ne 'ARRAY') {
+		my $href = $fary;
+		if(ref $href ne 'HASH') {
+			$href = { $fary, $vary, @_ }
+		}
+		$vary = [ values %$href ];
+		$fary = [ keys   %$href ];
+	}
+
 	if(defined $tkey) {
 		my $fstring = join ",", map { "$_=?" } @$fary;
 		$sql = "update $s->[$TABLE] SET $fstring WHERE $s->[$KEY] = $tkey";
@@ -1646,7 +1655,7 @@
 	}
 } # MVSEARCH
 #::logDebug("finished query, rc=$rc ref=$ref arrayref=$opt->{arrayref} Tmp=$Vend::Interpolate::Tmp->{$opt->{arrayref}}");
-	if(ref $ref) {
+	if(CORE::ref($ref)) {
 		# make sure rc is set if we got a ref from MVSEARCH
 		$rc = scalar @{$ref};
 	}