[Bug 21836] Remove NotSupportedError on creating index for multiEntry index with array keyPath

https://www.w3.org/Bugs/Public/show_bug.cgi?id=21836

Jonas Sicking <jonas@sicking.cc> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jonas@sicking.cc

--- Comment #2 from Jonas Sicking <jonas@sicking.cc> ---
There are several ways that you could interpret an array keyPath on a
multiEntry index.

Consider a multiEntry index with keyPath ["a", "b"]

It's pretty intuitive that storing a value like:

{
  id: 1,
  a: "apple",
  b: "orange"
}

would add the following entries to the index:

"apple" -> 1
"orange" -> 1


But what would storing the following value result in?

{
  id: 1,
  a: ["apple", "x"],
  b: ["orange", "y"]
}

Would this result in the following entries

A)
["apple", "x"] -> 1
["orange", "y"] -> 1

or

B)
"apple" -> 1
"x" -> 1
"orange" -> 1
"y" -> 1

or

C)
["apple", "orange"] -> 1
["x", "y"] -> 1


Normally when an Array is used as a KeyPath the resulting key consists of an
Array where each entry in the Array is the result of evaluating that KeyPath.
So in this example the result would be

[["apple", "x"], ["orange", "y"]]

Applying normal multiEntry processing to that key would mean that behavior A)
above is the correct answer.


However a common use-case for multiEntry+Array-KeyPath is likely things like
creating a "name" index which indexes on both first names and last names. In
that case you'd likely want the union of all values from each element in the
Array. I.e. you'd want behavior B) above.


Another way to look at it is that just like adding multiEntry to an index on
"a" lets you store an Array in the "a" property to add one entry for each value
in that array, so could adding multiEntry to an index on ["a", "b"] let you
store Arrays in the "a" and "b" properties to add one entry for each value in
those two arrays. This interpretation says that C) above is the correct
behavior.


So I'm somewhat inclined to solve the use cases here using bug 10000. Or to use
some other flag here than "multiEntry" which more clearly indicates which of
the behaviors above should be used.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Monday, 29 April 2013 11:17:37 UTC