Skip to content

Commit

Permalink
Using overwritten property or native type when resolving custom SELEC…
Browse files Browse the repository at this point in the history
…T type.
  • Loading branch information
gaspard committed Apr 11, 2011
1 parent 24c6104 commit 5a04895
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion app/models/virtual_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,16 @@ def safe_method_type(signature, receiver = nil)
if query.select_keys.include?(method)
# Resolve by using information in the SELECT part
# of the custom_query that found this node
return {:class => String, :method => "attributes[#{method.inspect}]", :nil => true}

# In order to use types other then String, we use the overwritten property's
# type.
if type = safe_column_types[method]
return type.merge(:method => "attributes[#{method.inspect}]", :nil => true)
elsif type = real_class.safe_method_type(signature)
return type.merge(:nil => true)
else
return {:class => String, :method => "attributes[#{method.inspect}]", :nil => true}
end
end
end
if type = safe_column_types[method]
Expand Down
2 changes: 1 addition & 1 deletion test/custom_queries/complex.host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# roger 1 radio[~24]

Node:
# find all courses that an employee must follow
# Used to test custom select types (repeat_every, last_date)
emp_form_date:
# find courses assigned_to pages in job assigned_to CURRENT_NODE (employee)
main_table: courses
Expand Down
6 changes: 3 additions & 3 deletions test/integration/zafu_compiler/complex_ok.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ it_should_compile_custom_select:
visitor: complex_admin
site: complex
ref_date: 2004-09-01
src: "<r:emp_form_dates do='each' join=', '><r:show attr='title'/>(<r:priority/>)</r:emp_form_dates>"
tem: '/var2.attributes\["priority"\]/'
res: 'how to use the winch(10), secure a site(10), dangerous transportations(10), engine maintenance(5), information transmission(5), fiber junction(5), problem formulation(5), how to use the radio(1)'
src: "<r:emp_form_dates do='each' join=', '><r:show attr='title'/>(<r:priority/>)[<r:last_date format='%Y-%m'/>]</r:emp_form_dates>"
tem: '/var2.attributes\["priority"\].*\[<%= format_date\(var2.attributes\["last_date"\], :format => "%Y-%m"\) %>\]/'
res: 'how to use the winch(10)[], secure a site(10)[], dangerous transportations(10)[2004-03], engine maintenance(5)[], information transmission(5)[2002-05], fiber junction(5)[2003-03], problem formulation(5)[2006-03], how to use the radio(1)[]'

it_should_group_by_custom_select:
context:
Expand Down

0 comments on commit 5a04895

Please sign in to comment.