In DataMapper 0.10.2, on lines 184-189 of shared_adapter_spec, there
is  an example I have a question about. Here's the code:

          it 'should be able to search for objects in an empty list
and another OR condition (match none on the empty list)' do
            Heffalump.all(:conditions =>
DataMapper::Query::Conditions::Operation.new(
                                           :or,

DataMapper::Query::Conditions::Comparison.new(:in,
Heffalump.properties[:color], []),

DataMapper::Query::Conditions::Comparison.new(:in,
Heffalump.properties[:num_spots], [5]))).should == [ @five ]
          end

The test context sets up a table of Heffalump objects like this:

| Name  | color | num_spots |
| @red  | red   | nil       |
| @two  | nil   | 2         |
| @five | nil   | 5         |


In DataMapper's backend-neutral query format, the query looks like this:

  ((color IN [] OR num_spots IN [5]))

I read this as "color is unset OR it has 5 spots".

According to the spec, this should return just the @five object.  It
seems to me it should return both @five and @two, since they both
match the first part of the condition (color is unset).  This is what
the SimpleDB adapter currently returns.

If anyone could explain the rationale behind the example I'd greatly
appreciate it.  Thanks!

-- 
Avdi

Home: http://avdi.org
Developer Blog: http://avdi.org/devblog/
The Lazy Faire: http://thelazyfaire.org
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com

-- 
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