title: Querying an IndexedDB compound index with a shorter array
body: <p>IndexedDB allows you to make indexes on multiple properties. Like if you have objects like <code>{a: 0, b: 0}</code> you can make an index on <code>a</code> and <code>b</code>.</p>
  
  <p>The behavior of compound indexes is <a href="https://stackoverflow.com/a/15625231/786644">pretty weird</a>, but apparently it is supposed to be possible to query with an array that is shorter than the compound index. So in my example, I should be able to query on something like <code>[0]</code> and get results for a==0.</p>
  
  <p>But I can't seem to get that to work. Here's an example which <a href="http://jsbin.com/megaranehuja/1/" rel="nofollow noreferrer">you can run on JS Bin</a>:</p>
  
  <pre><code>var db;
  
  request = indexedDB.open("test", 1);
  request.onerror = function (event) { console.log(event); };
  
  request.onupgradeneeded = function (event) {
    var db = event.target.result;
    db.onerror = function (event) { console.log(event); };
  
    var store = db.createObjectStore("store", {keyPath: "id", autoIncrement: true});
    store.createIndex("a, b", ["a", "b"], {unique: true});
  
    store.add({a: 0, b: 0});
    store.add({a: 0, b: 1});
    store.add({a: 1, b: 0});
    store.add({a: 1, b: 1});
  };
  
  request.onsuccess = function (event) {
    db = request.result;
    db.onerror = function (event) { console.log(event); };
  
    console.log("Only [0, 0]");
    db.transaction("store").objectStore("store").index("a, b").openCursor(IDBKeyRange.only([0, 0])).onsuccess = function (event) {
      var cursor = event.target.result;
      if (cursor) {
        console.log(cursor.value);
        cursor.continue();
      } else {
        console.log("Any [0, x]");
        db.transaction("store").objectStore("store").index("a, b").openCursor(IDBKeyRange.only([0])).onsuccess = function (event) {
          var cursor = event.target.result;
          if (cursor) {
            console.log(cursor.value);
            cursor.continue();
          }
        };
      }
    };
  };
  </code></pre>
  
  <p><a href="http://jsbin.com/megaranehuja/1/" rel="nofollow noreferrer">Here is the JS Bin link again.</a></p>
  
  <p>The output I see is:</p>
  
  <pre><code>Only [0, 0]
  Object {a: 0, b: 0, id: 1}
  Any [0, x]
  </code></pre>
  
  <p>But I was hoping to see:</p>
  
  <pre><code>Only [0, 0]
  Object {a: 0, b: 0, id: 1}
  Any [0, x]
  Object {a: 0, b: 0, id: 1}
  Object {a: 0, b: 1, id: 2}
  </code></pre>
  
  <p>Where am I going wrong?</p>