I came across quite unexpected behaviour of Sequel today. In short:

When I first use graph and then select_append, everything works correctly:

DB[:profiles].graph(:consents, member_id: 
:member_id).select_append(Sequel.lit('m').as(:letter))
=> #<Sequel::Postgres::Dataset: "SELECT \"profiles\".\"id\", 
\"profiles\".\"member_id\", [...] \"consents\".\"member_id\" AS 
\"consents_member_id\", m AS \"letter\" FROM \"profiles\" LEFT OUTER JOIN 
\"consents\" ON (\"consents\".\"member_id\" = \"profiles\".\"member_id\")">

However, when order is different, it throws an error:

DB[:profiles].select_append(Sequel.lit('m').as(:letter)).graph(:consents, 
member_id: :member_id)
Sequel::Error: can't figure out alias to use for graphing for 
#<Sequel::LiteralString "*">
from 
/Users/pawel/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/sequel-5.1.0/lib/sequel/dataset/graph.rb:145:in
 
`block in graph'
from 
/Users/pawel/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/sequel-5.1.0/lib/sequel/dataset/graph.rb:144:in
 
`map'
from 
/Users/pawel/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/sequel-5.1.0/lib/sequel/dataset/graph.rb:144:in
 
`graph'
from (irb):6
from /Users/pawel/.rbenv/versions/2.4.2/bin/irb:11:in `<main>'

This is because #<Sequel::LiteralString "*"> does not meet any conditions 
from case here in _has_key_symbol 
method: 
https://github.com/jeremyevans/sequel/blob/2622077e57ac884538b2bd3bbae3d2ff6b02adb9/lib/sequel/dataset/actions.rb#L1106

Is this a correct behaviour? Should order matter in this case?

Regards,
Paweł 

-- 
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 https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to