Recursive inner join example


#1

Is there any example showing recursive inner joins in ROM?
I’m trying the following code:

sort_levels(selector).each.with_index do |(type, value), index|
  if index == 0
    query = query.prefix("level_0").qualified.where("level_0_type" => type.to_s).where("level_0_name" => value)
  else
    query = query.prefix("level_#{index}").qualified.inner_join(:nodes, "level_#{index}_parent_id" => "level_#{index-1}_id")                                          
  end                                                                                                                                                                 
end    

but I get “table name ‘nodes’ specified more than once”.


#2

Please report it as an issue in rom-sql. A small repro script would be very useful too.