On Friday, May 26, 2017 at 5:31:39 AM UTC-7, Simon Dahlbacka wrote:
>
> a dataset has a .columns property that is an array of symbols, but is it 
> possible to somehow get back the actual column name?
> basically, if the dataset is 
>
> ds = DB[:foo].select(Sequel.alias(:bar, :something_entirely_different))
>
> then ds.columns would be [:something_entirely_different]
>
> is it possible to get back :bar somehow, i.e. the actual column name 
> before it was aliased?
>
> I would want to manipulate the dataset before executing the query, by 
> adding an additional where clause based on bar column
>

You can introspect the content using Dataset#opts:

  select = ds.opts[:select] # [Sequel::SQL::AliasedExpression instance]

 And from there use the Sequel API:

  select[0].expression # => :bar

There are internal helper methods that do this:

  ds.send(:unaliased_identifier, select[0]) # => :bar

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

Reply via email to