Hi all,
I use Sequel to model two tables that I join using a one_to_manyassociation:
class Node < Sequel::Model
plugin :validation_helpers
one_to_many :node_data
end
class NodeDatum < Sequel::Model
many_to_one :node
end
I then get the objects I need from the database as follows:
Node.where(:name=>name).eager_graph(:node_data).order(:id).all.map { |a|
a.values.merge(:node_data=>a.node_data.map{|al| al.values})
}
But I need to call an extra DB function on the rows from the nodes table,
which I normally do like this:
Node.select_append(Sequel.function(:collect_member_geometries, :members))
I can add select_append to the Sequel clause, after eager_graph:
Node.where(:name=>name).eager_graph(:node_data)
.select_append(Sequel.function(:collect_member_geometries, :members))
.order(:id).all.map { |a|
a.values.merge(:node_data=>a.node_data.map{|al| al.values})
}
Then the resulting column, however, seems to get lost in the calling of
eager_graph. What should I do or change to keep using Sequel's model
associations and eager_graph while being able to add extra columns to the
original model?
Many thanks,
Bert Spaan
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.