On Wednesday, December 19, 2012 4:37:30 AM UTC-8, Geraldo Lopes de Souza 
wrote:
>
> I'm playing with dataset and graph, and for the record I was able to: 
>
> # select one table and joint it self restricting the fields of joined 
> relation with :select 
> ds = DB[:employees___employee].graph(:employees, {:employee_id 
> => :manager_id}, {:table_alias => :manager, :select => 
> [:first_name  ]}) 
>
> # pick just the fields from the main relation i want 
> ds = ds.set_graph_aliases(:first_name => :employee, :last_name 
> => :employee ) 
>
> # filter on the fields of the joined relation 
> ds = ds.filter(Sequel.like(:manager__first_name, "A 
> %", :case_insensitive=>true)) 
>
> What I'm trying to do without success is use an expression like 
> Sequel::SQL::Function.new('upper', :employee__last_name). 
>
> ds = ds.set_graph_aliases(:first_name => :employee, 
>                           :last_name => :employee, 
>                           :upper_name => [:employees, :upper_name, 
> Sequel::SQL::Function.new('upper', :employee__last_name)], 
>                           :first_name => :manager) 
>

There are two issues here.  First, you are :first_name alias twice, which 
is why the ":first_name => :employee" part is getting ignored.  Notice how 
"employee"."first_name" doesn't appear in the SQL.  Second, the cause of 
your error is probably that you are using :employees instead of :employee 
as the first element in the :upper_name value array.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/kNY3zQ4Cvt4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to