Project

General

Profile

Actions

Defect #6472

closed

"Gantt" doesn't work with oracle database

Added by Nelzin Alexander about 14 years ago. Updated about 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
2010-09-23
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

ArgumentError in Gantts#show 

Showing app/views/gantts/show.html.erb where line #180 raised: 
comparison of Date with Time failed

Extracted source (around line #180): 
177:     i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
178:     i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )
179:     
180:     i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
181:     
182:     i_left = ((i_start_date - @gantt.date_from)*zoom).floor     
183:     i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2                  # total width of the issue (- 2 for left and right borders)

RAILS_ROOT: /Users/alexander_nelzin/Sites/redmine-1.0

To get rid of this error we should convert comparable variables to one type.
I converted Time variables i_start_date and i_end_date to Date in lines 177 and 178

    i_start_date = (i.start_date >= @gantt.date_from ? i.start_date.to_date : @gantt.date_from )
    i_end_date = (i.due_before <= @gantt.date_to ? i.due_before.to_date : @gantt.date_to )

Also after this fix another comparison error appears

TypeError in Gantts#show 

Showing app/views/gantts/show.html.erb where line #184 raised: 
can't convert Date into Float

Extracted source (around line #184): 
181:     
182:     i_left = ((i_start_date - @gantt.date_from)*zoom).floor     
183:     i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2                  # total width of the issue (- 2 for left and right borders)
184:     d_width = ((i_done_date - i_start_date)*zoom).floor - 2                     # done width
185:     l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
186:   css = "task " + (i.leaf? ? 'leaf' : 'parent')
187:     %>

To fix it we should convert i_done_date to Date time again, because in line 176 it becomes float:

    i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor

Here is my patch to make Gantts work:

Index: app/views/gantts/show.html.erb
===================================================================
--- app/views/gantts/show.html.erb    (revision 1537)
+++ app/views/gantts/show.html.erb    (revision 1550)
@@ -170,10 +170,10 @@
 top = headers_height + 10
 @gantt.events.each do |i| 
   if i.is_a? Issue 
-    i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from )
-    i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to )
-    
-    i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
+    i_start_date = (i.start_date >= @gantt.date_from ? i.start_date.to_date : @gantt.date_from )
+    i_end_date = (i.due_before <= @gantt.date_to ? i.due_before.to_date : @gantt.date_to )
+
+    i_done_date = (i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor).to_date
     i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
     i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )

Note. The revisions shown here are my local revisions, not yours.


Files

gantt_dates_fix.diff (1016 Bytes) gantt_dates_fix.diff Nelzin Alexander, 2010-09-23 10:43

Related issues

Related to Redmine - Feature #944: Oracle Support in RedmineClosed2008-03-28

Actions
Actions #1

Updated by Nelzin Alexander about 14 years ago

My environment:
Redmine 1.0.1.stable.1536 (OracleEnhanced)

~/Sites/redmine-1.0 $ ruby script/about
About your application's environment
Ruby version              1.8.7 (universal-darwin10.0)
RubyGems version          1.3.5
Rack version              1.0
Rails version             2.3.5
Active Record version     2.3.5
Active Resource version   2.3.5
Action Mailer version     2.3.5
Active Support version    2.3.5
Application root          /Users/alexander_nelzin/Sites/redmine-1.0
Environment               development
Database adapter          oracle_enhanced
Database schema version   20100819172912

Actions #2

Updated by Nelzin Alexander about 14 years ago

I also tested these changes with postgres. Works fine.
Redmine 1.0.1.stable.1536 (PostgreSQL)
PostgreSQL server 8.4.4

~/Sites/redmine-1.0-postgres $ ruby script/about
About your application's environment
Ruby version              1.8.7 (universal-darwin10.0)
RubyGems version          1.3.5
Rack version              1.0
Rails version             2.3.5
Active Record version     2.3.5
Active Resource version   2.3.5
Action Mailer version     2.3.5
Active Support version    2.3.5
Application root          /Users/alexander_nelzin/Sites/redmine-1.0-postgres
Environment               development
Database adapter          postgresql
Database schema version   20100819172912

Actions #3

Updated by Felix Schäfer about 14 years ago

This seems to be a problem with the Oracle adapter casting @Date@s to @Time@s, on my development rig, I have:

>> Issue.find(1).start_date.class
=> Date

Which negates the need to explicitly recast start_date to a Date.

Actions #4

Updated by Nelzin Alexander about 14 years ago

You are right, it seems to look like oracle or oracle adapter "feature".

>> Issue.find(1).start_date.class
=> Time

Actions #5

Updated by Felix Schäfer about 14 years ago

  • Status changed from New to Closed

This behavior is described in the "Date, integer and boolean data types" section of the usage wiki page for the adapter: http://wiki.github.com/rsim/oracle-enhanced/usage. You will have to take care and maintain any changes yourself, as oracle is not supported and we won't add stuff specific to that adapter in core, sorry. If you do maintain a branch working with oracle and it is public, it would be nice to advertise that in the forums or make a note of it on the installation page though :-)

Actions

Also available in: Atom PDF