[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#240459: Patch of bug #240459



Hello

I send patch of bug in dia2sql.
Problem specification:
dia2sql required one attribute in each UML class defined as protected.
Protected atributes were considered as Primary keys in SQL query.
If this Protected type of attribute were missing dia2sql crahses.

I added small control. If attribute is missing, dia2sql will print
warning message, but continues in execution.

Have a nice day

	Georgik
-- 
-=- -=- -=- -=- -=- -=- -=- -=- -=- -=- -=- -=- -=- -=-
 Bc. Juraj Michalek - http://georgik.blucina.net
       Every application is a game. 
 The question is: How much you can enjoy it.
   Games for Linux - http://games.linux.sk
--- /usr/bin/dia2sql	2004-01-17 04:40:16.000000000 +0100
+++ dia2sql.new	2004-04-29 07:48:23.000000000 +0200
@@ -377,16 +377,23 @@
 
 	if($DEBUG) { print STDERR "-> Collect table columns\n"; }
 	my $columns = join(",\n\t",@{$myTableContents{$tablename}});
-	my $keys = "PRIMARY KEY(".join(",",@{$myPrimaryKeys{$tablename}}).")";
+	my $index = $myPrimaryKeys{$tablename};
+	my $keys;
+	if (defined($index)) {
+		$keys = "PRIMARY KEY(".join(",",@{$index}).")";
+	}
+
 
 	if($DEBUG) { print STDERR "-> Create CREATE TABLE statement\n"; }
 	my $sql = "CREATE TABLE $tablename (\n\t".$columns;
 
-	if(@{$myPrimaryKeys{$tablename}}) {
+	if(defined(@{$myPrimaryKeys{$tablename}})) {
 		if($DEBUG) { print STDERR "-> Adding PRIMARY KEY definitions\n"; }
 		$sql .= ",\n\t".$keys."\n);\n\n";
 	} else {
 		$sql .= "\n);\n\n";
+		print STDERR "-> Warning: Primary key not defined! Set primary atribute".
+			" as Protected in dia model\n\n";
 	}
 
 	print $sql;

Reply to: