Project

General

Profile

Actions

Defect #4533

closed

ARCondition not handling dup/clone

Added by Felix Schäfer over 14 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
High
Assignee:
-
Category:
-
Target version:
-
Start date:
2010-01-07
Due date:
% Done:

0%

Estimated time:
Resolution:
Wont fix
Affected version:

Description

Long story short: ARCondition#clone and #dup create new objects, but all objects created this way somehow share the string in @conditions[0].

s = ARCondition.new "#{Issue.table_name}.assigned_to_id IS NOT NULL" 
p = s.clone
s << ["#{Issue.table_name}.start_date <= ?", Date.today]
p

Results in:

$ script/console 
Loading development environment (Rails 2.3.5)
>> s = ARCondition.new "#{Issue.table_name}.assigned_to_id IS NOT NULL" 
=> #<ARCondition:0x102bbb040 @conditions=["1=1 AND (issues.assigned_to_id IS NOT NULL)"]>
>> p = s.clone
=> #<ARCondition:0x102baac68 @conditions=["1=1 AND (issues.assigned_to_id IS NOT NULL)"]>
>> s << ["#{Issue.table_name}.start_date <= ?", Date.today]
=> #<ARCondition:0x102bbb040 @conditions=["1=1 AND (issues.assigned_to_id IS NOT NULL) AND (issues.start_date <= ?)", Thu, 07 Jan 2010]>
>> p
=> #<ARCondition:0x102baac68 @conditions=["1=1 AND (issues.assigned_to_id IS NOT NULL) AND (issues.start_date <= ?)"]>

Notice p got the condition added to s but not the parameter.

I was able to get around this by being a little more brutal, but I don't think that's how it should work:

p = ARCondition.new s.conditions
Actions

Also available in: Atom PDF