Yup.

YourClass.all(:color => /green/) + YourClass.all(:color => /red/)

'course that'll use regexps rather than a LIKE.  Regardless you can merge
any two queries by using the :+ method on collections.  Likewise you can
use :- to do disjunctive queries too.


On Sat, Dec 8, 2012 at 9:28 AM, berpel <ber...@path.to> wrote:

> class Object
>     include DataMapper::Resource
>     property :id, Serial
>     property :name
>     property :color, String #ex. "red green yellow"
>     property :shape, String #ex. "square circle triangle"
> end
>
> Is there a way to return a result set from DataMapper that looks something
> like this?
>
> SELECT * FROM names WHERE color LIKE '%green%' or color LIKE '%red%' LIMIT
> 30
>
> I know I can query each LIKE independently and join the two queries but
> that messes up my LIMIT and I could also potentially have other 
> LIKEconditions on other fields and the whole gets hairy.
>
> Thanks,
> Brett
>
> --
> 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/-/kOBzN9eDO7oJ.
> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
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