I have a similar issue, but have a number of columns that have this double
underscore issue. So I hijacked the SPLIT_SYMBOL_CACHE:
DB.extend_datasets do
def ignore_double_underscores
columns.each do |col|
if col.to_s.include?('__')
Sequel.synchronize{Sequel::SPLIT_SYMBOL_CACHE[col] = [nil,
col.to_s, nil]}
end
end
end
end
ds.ignore_double_underscores
Is there a better way?
On Tuesday, March 3, 2015 at 5:25:19 PM UTC-5, Jeremy Evans wrote:
>
> 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.