From a03cab50c908c41f6f1318eac9bc2d63ad772c52 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 7 Mar 2004 17:16:52 +0000 Subject: [PATCH] bug fixes --- docs/gotcha.txt | 9 +++++++++ docs/upgrades/upgrade_5.9.9-6.0.0.pl | 25 ++++++++++++------------- lib/WebGUI/SQL.pm | 4 ++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 195dfa6f6..706ae367d 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -63,6 +63,15 @@ save you many hours of grief. nothing to worry about. All of the theme components will automatically be converted to 6.0. + * If you have any SQL Reports going against any USS, they will need + to be updated as the USS tables have changed. + + * During the upgrade process you may see some database errors during + the migration of SQL Reports. Don't be alarmed. Your upgrade + has not failed. Instead, some of the queries in the SQL Reports + may have failed and will cause the SQL Report templates to not + be automatically generated. + 5.5.0 -------------------------------------------------------------------- diff --git a/docs/upgrades/upgrade_5.9.9-6.0.0.pl b/docs/upgrades/upgrade_5.9.9-6.0.0.pl index 569db4be8..452ab6ee0 100644 --- a/docs/upgrades/upgrade_5.9.9-6.0.0.pl +++ b/docs/upgrades/upgrade_5.9.9-6.0.0.pl @@ -400,10 +400,8 @@ WebGUI::SQL->write("delete from incrementer where incrementerId='LinkList_linkId #-------------------------------------------- print "\tUpdating SQL Reports.\n" unless ($quiet); my %dblink; -$dblink{$session{config}{dsn}} = ( - id=>0, - user=>$session{config}{dbuser} - ); +$dblink{$session{config}{dsn}}{id} = 0; +$dblink{$session{config}{dsn}}{user} = $session{config}{dbuser}; my $sth = WebGUI::SQL->read("select DSN, databaseLinkId, username, identifier, wobjectId from SQLReport"); while (my $data = $sth->hashRef) { my $id = undef; @@ -419,10 +417,8 @@ while (my $data = $sth->hashRef) { my $title = $data->{username}.'@'.$data->{DSN}; WebGUI::SQL->write("insert into databaseLink (databaseLinkId, title, DSN, username, identifier) values ($id, ".quote($title).", ".quote($data->{DSN}).", ".quote($data->{username}).", ".quote($data->{identifier}).")"); - $dblink{$data->{DSN}} = ( - id=>$id, - user=>$data->{username} - ); + $dblink{$data->{DSN}}{id} = $id; + $dblink{$data->{DSN}}{user} = $data->{username}; } WebGUI::SQL->write("update SQLReport set databaseLinkId=".$id." where wobjectId=".$data->{wobjectId}); } @@ -432,9 +428,9 @@ WebGUI::SQL->write("alter table SQLReport drop column username"); WebGUI::SQL->write("alter table SQLReport drop column identifier"); use WebGUI::DatabaseLink; my $templateId; -my $a = WebGUI::SQL->read("select a.databaseLinkId, a.dbQuery, a.template, a.wobjectId, b.title from SQLReport a - left join wobject b on a.wobjectId=b.wobjectId"); +my $a = WebGUI::SQL->read("select a.databaseLinkId, a.dbQuery, a.template, a.wobjectId, b.title from SQLReport a , wobject b where a.wobjectId=b.wobjectId"); while (my $data = $a->hashRef) { + next if ($data->{dbQuery} eq ""); my $db = WebGUI::DatabaseLink->new($data->{databaseLinkId}); if ($data->{template} ne "") { ($templateId) = WebGUI::SQL->quickArray("select max(templateId) from template where namespace='SQLReport'"); @@ -463,11 +459,13 @@ while (my $data = $a->hashRef) { '.$template[0].' '; my $i; + if (defined $b) { foreach my $col ($b->getColumnNames) { my $replacement = ''; $template[1] =~ s/\^$i\;/$replacement/g; $i++; } + } $template[1] =~ s/\^rownum\;/\/g; $final .= $template[1].' @@ -482,7 +480,8 @@ while (my $data = $a->hashRef) { } else { $templateId = 1; } - WebGUI::SQL->write("insert into wobject set templateId=$templateId where wobjectId=".$data->{wobjectId}); + WebGUI::SQL->write("update wobject set templateId=$templateId where wobjectId=".$data->{wobjectId}); + print "\tend loop\n"; } $a->finish; WebGUI::SQL->write("alter table SQLReport drop column template"); @@ -605,13 +604,13 @@ while (my ($surveyId) = $a->array) { while (my ($userId) = $b->array) { my ($username,$ipAddress) = WebGUI::SQL->quickArray("select username,ipAddress from Survey_questionResponse where Survey_id=$surveyId and userId=".quote($userId)); - WebGUI::SQL->write("insert into (Survey_id, Survey_responseId, userId, username, isComplete, ipAddress) values ($surveyId, + WebGUI::SQL->write("insert into Survey_response (Survey_id, Survey_responseId, userId, username, isComplete, ipAddress) values ($surveyId, ".getNextId("Survey_responseId")." ,".quote($userId).", ".quote($username).", 1, ".quote($ipAddress).")"); } $b->finish; $b = WebGUI::SQL->read("select distinct ipAddress from Survey_questionResponse where Survey_id=$surveyId and userId='1'"); while (my ($ipAddress) = $b->array) { - WebGUI::SQL->write("insert into (Survey_id, Survey_responseId, userId, username, isComplete, ipAddress) values ( + WebGUI::SQL->write("insert into Survey_response (Survey_id, Survey_responseId, userId, username, isComplete, ipAddress) values ( $surveyId, ".getNextId("Survey_responseId")." ,'1', 'Visitor', 1, ".quote($ipAddress).")"); } $b->finish; diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index 75ef85d53..d2a4ed571 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -679,7 +679,11 @@ sub unconditionalRead { if ($sth) { $sth->execute or WebGUI::ErrorHandler::warn("Unconditional read failed: ".$_[1]." : ".DBI->errstr); bless ({_sth => $sth}, $_[0]); + unless (DBI->errstr) { + return; + } } + return undef; }