Thank you Jeremy.
I'm playing with dataset syntax to choose which one to use.
I rewrote as:
ds = DB[:employees___employee].select(:first_name, :last_name,
Sequel::SQL::Function.new('upper',
:last_name).as(:upper_last_name)).graph(:employees,
{:employee_id => :manager_id}, {:table_alias => :manager, :select =>
[:first_name ]})
If you use set_graph_aliases to select which fields you want kind of
defeats the advantage of the graph that is no need to alias
everything.
Note that I'm using select on the main dataset. and :select option on
the graphed one to choose which fields I want. Is that allowed ?
Regards,
Geraldo Lopes de Souza
On Dec 19, 2:54 pm, Jeremy Evans <[email protected]> wrote:
> 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 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.