[Rt-commit] rt branch, 4.2/pg-timeworked-bulletproof, created. rt-4.1.8-573-g5489991
Alex Vandiver
alexmv at bestpractical.com
Thu Jun 13 19:06:24 EDT 2013
The branch, 4.2/pg-timeworked-bulletproof has been created
at 548999105bfb18399f118c1fcc6f96b64d0b2145 (commit)
- Log -----------------------------------------------------------------
commit 548999105bfb18399f118c1fcc6f96b64d0b2145
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Jun 13 18:56:04 2013 -0400
Prevent errors in cases where OldValue is NULL
In sufficiently old or inconsistent databases, OldValue may be NULL; on
Pg, this results in a fatal error. On all databases, error-proof by
assuming that values of NULL are really 0 and continue.
diff --git a/etc/upgrade/4.1.7/schema.Oracle b/etc/upgrade/4.1.7/schema.Oracle
index 219eefa..b53dceb 100644
--- a/etc/upgrade/4.1.7/schema.Oracle
+++ b/etc/upgrade/4.1.7/schema.Oracle
@@ -1,5 +1,5 @@
UPDATE Transactions
SET TimeTaken
= COALESCE(TO_NUMBER(REGEXP_SUBSTR(NewValue, '^-?\d+$')), 0)
- - TO_NUMBER(OldValue)
+ - COALESCE(TO_NUMBER(OldValue),0)
WHERE ObjectType = 'RT::Ticket' AND Type = 'Set' AND Field = 'TimeWorked';
\ No newline at end of file
diff --git a/etc/upgrade/4.1.7/schema.Pg b/etc/upgrade/4.1.7/schema.Pg
index b6a8e1f..2949e32 100644
--- a/etc/upgrade/4.1.7/schema.Pg
+++ b/etc/upgrade/4.1.7/schema.Pg
@@ -1,6 +1,5 @@
UPDATE Transactions
-SET TimeTaken = (
- (CASE WHEN NewValue~E'^-?\\d+$' THEN NewValue::integer ELSE 0 END)
- - OldValue::integer
-)
+SET TimeTaken
+ = (CASE WHEN NewValue~E'^-?\\d+$' THEN NewValue::integer ELSE 0 END)
+ - COALESCE(OldValue::integer, 0)
WHERE ObjectType = 'RT::Ticket' AND Type = 'Set' AND Field = 'TimeWorked';
\ No newline at end of file
diff --git a/etc/upgrade/4.1.7/schema.mysql b/etc/upgrade/4.1.7/schema.mysql
index 8d6680d..95013f3 100644
--- a/etc/upgrade/4.1.7/schema.mysql
+++ b/etc/upgrade/4.1.7/schema.mysql
@@ -1,2 +1,5 @@
-UPDATE Transactions SET TimeTaken = NewValue - OldValue
+UPDATE Transactions
+SET TimeTaken
+ = COALESCE(NewValue,0)
+ - COALESCE(OldValue,0)
WHERE ObjectType = 'RT::Ticket' AND Type = 'Set' AND Field = 'TimeWorked';
\ No newline at end of file
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list