Hello Jeremy 

Thank you for your advice. 

It seems good. 

def find_from_top_join(search_path)
  ds = FileTree.roots_dataset.from_self
  search_path[1..-1].split('/').each_with_index do |name, i|
    ds = ds.join(Sequel.as(:file_trees, "n#{i}") , :parent_id=>:id, 
:name=>name)
  end
  ds.first
end


def find_from_top(search_path)
  current = FileTree.root
  search_path[1..-1].split('/').each do |name|
    break unless current = current.children_dataset.first(:name=>name)
  end
  current
end


--
Hiroyuki Sato.



2014年7月2日水曜日 0時01分52秒 UTC+9 Jeremy Evans:
>
> On Tuesday, July 1, 2014 2:45:52 AM UTC-7, Hiroyuki Sato wrote:
>>
>> Hello Jeremy .
>>
>> Thank you for your advice.
>>
>> You mean that the folloiwng?
>>
>> I'll practice to  use join method. 
>>
>>
>>
>> def find_from_top_join(search_path)
>>   ds = FileTree.roots_dataset.from_self #<-- change here
>>   search_path[1..-1].split('/').each_with_index do |name, i|
>>     ds = ds.join(:file_trees.as("n#{i}"), :parent_id=>:id, :name=>name)
>>
>
> You could use Sequel.as(:file_trees, "n#{i}") here to avoid usage of the 
> core_extensions (no longer on by default for about a year).  Sorry I didn't 
> think about that the first time.
>  
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to