[interchange-cvs] interchange - jon modified 2 files

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Fri Jan 11 03:49:00 2002


User:      jon
Date:      2002-01-11 08:48:06 GMT
Modified:  lib/Vend Interpolate.pm
Modified:  lib/Vend/Table DBI.pm
Log:
A bugfix and a feature enhancement:

(1) Fix [prefix-param] for [query] when using mv_more_alpha.

In Vend::Interpolate::labeled_list, mv_field_hash was quietly getting
blown away if mv_field_names wasn't set (which it never was at that point).
That meant that [prefix-param field2] didn't work, but [prefix-pos 2] did.

(2) Eliminate the need to manually specify mv_return_fields with [query]
    when using mv_more_alpha.

Vend::Interpolate::tag_sql_list had no way of knowing what the return
fields were unless they were manually listed in the tag, like this:

[query
	list=1
	more=1
	sql="SELECT a,b,c,d,e FROM table"
	ma=1
	rf=a,b,c,d,e
]

Now you can leave off the extra field list in 'rf' and it's gotten from
the result set instead. (However, if specified, mv_return_fields overrides
the field names in the result set, in case you want to mess with those for
some reason.)

Revision  Changes    Path
2.37      +7 -4      interchange/lib/Vend/Interpolate.pm


rev 2.37, prev_rev 2.36
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.36
retrieving revision 2.37
diff -u -u -r2.36 -r2.37
--- Interpolate.pm	2002/01/09 19:22:50	2.36
+++ Interpolate.pm	2002/01/11 08:48:06	2.37
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.36 2002/01/09 19:22:50 jon Exp $
+# $Id: Interpolate.pm,v 2.37 2002/01/11 08:48:06 jon Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -27,7 +27,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.36 $, 10);
+$VERSION = substr(q$Revision: 2.37 $, 10);
 
 @EXPORT = qw (
 
@@ -4645,7 +4645,7 @@
 		my $fh = $obj->{mv_field_hash}    || undef;
 		my $fn = $obj->{mv_field_names}   || undef;
 		$ary = tag_sort_ary($opt->{sort}, $ary) if $opt->{sort};
-		if($fa) {
+		if ($fa and $fn) {
 			my $idx = 0;
 			$fh = {};
 			for(@$fa) {
@@ -4659,6 +4659,8 @@
 				$fh->{$_} = $idx++;
 			}
 		}
+		logError("Missing mv_field_hash and/or mv_field_names in Vend::Interpolate::labeled_list")
+			unless ref $fh eq 'HASH';
 		$r = iterate_array_list($i, $end, $count, $text, $ary, $opt_select, $fh);
 	}
 	$MVSAFE::Unsafe = $save_unsafe;
@@ -5506,7 +5508,7 @@
 
 # SQL
 sub tag_sql_list {
-    my($text,$ary,$nh,$opt) = @_;
+    my($text,$ary,$nh,$opt,$na) = @_;
 	$opt = {} unless defined $opt;
 	$opt->{prefix}      = 'sql' if ! defined $opt->{prefix};
 	$opt->{list_prefix} = 'sql[-_]list' if ! defined $opt->{prefix};
@@ -5514,6 +5516,7 @@
 	my $object = {
 					mv_results => $ary,
 					mv_field_hash => $nh,
+					mv_return_fields => $na,
 					matches => scalar @$ary,
 				};
 



2.9       +3 -3      interchange/lib/Vend/Table/DBI.pm


rev 2.9, prev_rev 2.8
Index: DBI.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Table/DBI.pm,v
retrieving revision 2.8
retrieving revision 2.9
diff -u -u -r2.8 -r2.9
--- DBI.pm	2001/12/07 00:20:28	2.8
+++ DBI.pm	2002/01/11 08:48:06	2.9
@@ -1,6 +1,6 @@
 # Vend::Table::DBI - Access a table stored in an DBI/DBD database
 #
-# $Id: DBI.pm,v 2.8 2001/12/07 00:20:28 jon Exp $
+# $Id: DBI.pm,v 2.9 2002/01/11 08:48:06 jon 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.8 $, 10);
+$VERSION = substr(q$Revision: 2.9 $, 10);
 
 use strict;
 
@@ -1722,7 +1722,7 @@
 	}
 	return $rc
 		if $opt->{row_count};
-	return Vend::Interpolate::tag_sql_list($text, $ref, \%nh, $opt)
+	return Vend::Interpolate::tag_sql_list($text, $ref, \%nh, $opt, \@na)
 		if $opt->{list};
 	return Vend::Interpolate::html_table($opt, $ref, \@na)
 		if $opt->{html};