[interchange-cvs] interchange - heins modified lib/Vend/Table/DBI_CompositeKey.pm

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Sun Apr 11 14:01:11 EDT 2004


User:      heins
Date:      2004-04-11 18:01:11 GMT
Modified:  lib/Vend/Table DBI_CompositeKey.pm
Log:
* Create unique index on COMPOSITE_KEY tables if no INDEX or POSTCREATE
  is present.

Revision  Changes    Path
1.5       +18 -2     interchange/lib/Vend/Table/DBI_CompositeKey.pm


rev 1.5, prev_rev 1.4
Index: DBI_CompositeKey.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Table/DBI_CompositeKey.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DBI_CompositeKey.pm	11 Apr 2004 16:34:50 -0000	1.4
+++ DBI_CompositeKey.pm	11 Apr 2004 18:01:11 -0000	1.5
@@ -1,6 +1,6 @@
 # Vend::Table::DBI - Access a table stored in an DBI/DBD database
 #
-# $Id: DBI_CompositeKey.pm,v 1.4 2004/04/11 16:34:50 mheins Exp $
+# $Id: DBI_CompositeKey.pm,v 1.5 2004/04/11 18:01:11 mheins Exp $
 #
 # Copyright (C) 2002-2004 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -21,7 +21,7 @@
 # MA  02111-1307  USA.
 
 package Vend::Table::DBI_CompositeKey;
-$VERSION = substr(q$Revision: 1.4 $, 10);
+$VERSION = substr(q$Revision: 1.5 $, 10);
 
 use strict;
 
@@ -82,6 +82,22 @@
 		else {
 			$config->{_Key_splittor} = qr([\0,]);
 		}
+	}
+	if(
+		(! $config->{INDEX} or @{$config->{INDEX}} == 0)
+		and
+		! $config->{POSTCREATE}
+	  )
+	{
+		my $fields = $config->{COMPOSITE_KEY};
+		$fields =~ s/^\s+//;
+		$fields =~ s/\s+$//;
+		$fields =~ s/\s+/,/g;
+
+		my $tabname = $config->{REAL_NAME} || $config->{name};
+		$config->{POSTCREATE} = 
+			["CREATE UNIQUE INDEX ${tabname}_index ON $tabname($fields)"];
+#::logDebug("did POSTCREATE: $config->{POSTCREATE}");
 	}
 
 #::logDebug("open_table config=" . ::uneval($config));








More information about the interchange-cvs mailing list