try doing changing #default_scope to overwrite what Discriminator sets
in your model. like M.default_scope(:some_repo).update(:type => 'm')

This is just a guess though, I haven't tried that.

On Feb 4, 12:26 pm, "Richard Head Jr." <hsomob1...@yahoo.com> wrote:
> (I sent this yesterday but did not see it on the list. Maybe it wasn't 
> approved..?)
>
> I have a legacy DB which cannot be modified. There is already a column named 
> type, it's a char(1) and contains lowercase chars, 'm' or 's'.
>
> class M < Spot
>   include DataMapper::Resource
>
>   property :type, Discriminator, :field => 'Type', :key => true, :writer => 
> :private, :default => 'm'
>   property :identifier, String, :length => 32, :field => 'Identifier', :key 
> => true
>
>  #relationships...
> end
>
> Spot is not a DataMapper resource.
>
> Based on the :type property's config I can write records with a lowercase 'm' 
> but, since the class' name is uppercase, when I retrieve records DataMapper 
> looks for a type column with an uppercase 'M'.
>
> I've been looking at the source trying to find a minimally invasive way to 
> fix this yet there seems to be none. Overriding conditions or query in 
> Resource looks OK but I'm concerned this could break how associations 
> (omitted from above example) are retrieved, or something else.
>
> Any good ways around this?
>
> Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to datamap...@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to