I caught the typos with the % sign after I posted. Still, as you said, that 
wouldn't cause the error but rather just not destroy anything.

I am using DM_VERSION = "~> 1.2.0". Basically, I cut and pasted what's in 
the dm-rails. I am not sure how you managed to make it work.

I have things working in a pure SQL way now, but any insight will be 
helpful.

Thanks.


On Wednesday, August 22, 2012 6:52:20 PM UTC-4, Chris Corbyn wrote:
>
> Way less readable and elegant though ;)  This is a bug.  DataMapper should 
> know that URI properties are dumped to strings, so that should be what it 
> does when it generates the query.
>
> That said, your original query is wrong.  It should have the '%' marks 
> around the search string:
>
> person.photos.all(:url.like => '%amazon%').destroy
>
> What version of DM are you using?  I just tried this with a model we use 
> URI types on and it worked as expected.  I tried it both directly on the 
> model, and by going through a 1:m relationship. (DM 1.2.0).
>
>
> Il giorno 23/ago/2012, alle ore 03:14, Abe Voelker ha scritto:
>
> Also from your example it looks like DM is pulling in the url field as 
> an Addressable::URI, so it is probably already fetching all the associated 
> records from the DB in order to load them into memory to parse 
> into Addressable::URI structures.  If that's the case, then I don't think 
> there would be any additional performance overhead from what you originally 
> had to just doing
>
> person.photos.all.select{|photo| photo.url.host.downcase == 'amazon.com'}
>
> On Wednesday, August 22, 2012 12:01:05 PM UTC-5, Abe Voelker wrote:
>>
>> Is this too SQL-ish?
>>
>> person.photos.all(:conditions => ['"url" ilike ?', "%amazon%"])
>>
>> On Wednesday, August 22, 2012 11:48:23 AM UTC-5, Neil C wrote:
>>>
>>> Besides, obviously, a SQL solution.
>>>
>>> Thanks.
>>>
>>>
>>>
>>> On Wednesday, August 22, 2012 12:45:52 PM UTC-4, Neil C wrote:
>>>>
>>>> I am trying to do the following:
>>>>
>>>> person.photos.all(:url.like => "amazon").destroy
>>>>
>>>> As you might guess, 1 person has n photos, and each photo has a url 
>>>> property. I am trying to remove any photos with "amazon" in the URL.
>>>>
>>>> When I do this, I get the following:
>>>>
>>>> NoMethodError: undefined method `gsub' for 
>>>> #<Addressable::URI:0x3fc672305d40 URI:amazon>
>>>>
>>>> Any insight into solving this is appreciated.
>>>>
>>>> Thanks.
>>>>
>>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "DataMapper" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/datamapper/-/K0BzmeduifoJ.
> To post to this group, send email to datam...@googlegroups.com<javascript:>
> .
> To unsubscribe from this group, send email to 
> datamapper+...@googlegroups.com <javascript:>.
> For more options, visit this group at 
> http://groups.google.com/group/datamapper?hl=en.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/datamapper/-/tu1FnD7DyuwJ.
To post to this group, send email to datamapper@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