On Tuesday, March 3, 2015 at 2:17:01 PM UTC-8, Neil Middleton wrote:
>
> Hey,
>
> I'm having some issues with double underscores that you may be able to 
> solve.
>
> Basically, for reasons outside of my control, I have a table with columns 
> such as `foo__c` as the column name.  What's more I'm trying to get this 
> table working in a legacy system so am having to also use 
> `def_column_alias` to make that column available as just `foo`.
>
> However, when trying to do things like create a record with factory_girl I 
> am seeing Sequel doing it's thing and assuming that the __ is table.column.
>
> Is there a way to tell Sequel to NOT do this in this particular case?  How 
> can I use column names that include a double underscore?
>

You can override Dataset#split_symbol on the appropriate dataset.  This 
method returns [table, column, alias] for the symbol.  So something like:

  DB.extend_datasets do
    def split_symbol(s)
      case s
      when /\Afoo__.+\z/
         [nil, s.to_s, nil]
      else
         super
      end
    end
  end

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

Reply via email to