[Rt-commit] rt branch, 4.0/upgrade-syntax-fixes, updated. rt-4.0.0-239-ge3ead5c

? sunnavy sunnavy at bestpractical.com
Wed May 18 06:26:15 EDT 2011


The branch, 4.0/upgrade-syntax-fixes has been updated
       via  e3ead5ce23321f8b0aa521232c7d83f473f761b6 (commit)
      from  90672de5de9f694c083218dbb8b574a671df27c4 (commit)

Summary of changes:
 etc/upgrade/3.9.7/content |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit e3ead5ce23321f8b0aa521232c7d83f473f761b6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 18 17:44:26 2011 +0800

    Pg needs the string => number cast too

diff --git a/etc/upgrade/3.9.7/content b/etc/upgrade/3.9.7/content
index f8073ed..a62a9b4 100644
--- a/etc/upgrade/3.9.7/content
+++ b/etc/upgrade/3.9.7/content
@@ -4,14 +4,24 @@ my %number_column = (
 my $move_attributes = sub {
     my ($table, $type, $column) = @_;
     my $query;
-    if ( $number_column{ $column } && RT->Config->Get('DatabaseType') eq 'Oracle' ) {
-        $query = "UPDATE $table SET $column = (SELECT TO_NUMBER(Content) FROM Attributes WHERE"
-            ." Name = ? AND ObjectType = ? AND $table.id = Attributes.ObjectId)";
-    } else {
-        $query = "UPDATE $table SET $column = (SELECT Content FROM Attributes WHERE"
-            ." Name = ? AND ObjectType = ? AND $table.id = Attributes.ObjectId)";
+    if ( $number_column{$column} ) {
+        if ( RT->Config->Get('DatabaseType') eq 'Oracle' ) {
+            $query =
+"UPDATE $table SET $column = (SELECT TO_NUMBER(Content) FROM Attributes WHERE"
+              . " Name = ? AND ObjectType = ? AND $table.id = Attributes.ObjectId)";
+        }
+        elsif ( RT->Config->Get('DatabaseType') eq 'Pg' ) {
+            $query =
+"UPDATE $table SET $column = (SELECT TO_NUMBER(Content, '99999999999') FROM Attributes WHERE"
+              . " Name = ? AND ObjectType = ? AND $table.id = Attributes.ObjectId)";
+        }
     }
 
+    $query ||=
+        "UPDATE $table SET $column = (SELECT Content FROM Attributes WHERE"
+      . " Name = ? AND ObjectType = ? AND $table.id = Attributes.ObjectId)";
+
+
     my $res = $RT::Handle->SimpleQuery( $query, $column, $type );
     unless ( $res ) {
         $RT::Logger->error("Failed to move $column on $type from Attributes into $table table");

-----------------------------------------------------------------------


More information about the Rt-commit mailing list