yathit / ydn-db

Javascript database module for Indexeddb, Web SQL and localStorage storage mechanisms supporting version migration, advanced query, SQL and transaction.
Apache License 2.0
503 stars 41 forks source link

Query with where & order always resolves with empty result #70

Closed dave-trudes closed 9 years ago

dave-trudes commented 9 years ago

Hi there, I'm using ydn at version 1.1.2 and have following schema:

stores: [{
  name: 'data',   
  keyPath: 'id',
  type: 'NUMERIC',

  indexes: [
    {
       name: 'status',
       keyPath: 'status',
        type: 'NUMERIC'
    },
    {
       name: 'status, location.name',
       keyPath: ['status', 'location.name']
     }
   ]
}]

// Insert values
db.put(data, [...])

After inserting values, the 'status, location.name' table is populated accordingly. If I then want to execute the following query, the promise always resolves empty.

db.from("data")
  .where("status", "=", 2)
  .order('location.name', true)
  .list()
  .done(resolve).fail(reject);
yathit commented 9 years ago

It looks ok. Could you post runnable code in jsbin?

Thanks

dave-trudes commented 9 years ago

Thank you for your quick reply. Here is the jsbin: http://jsbin.com/cewexewome/edit?js,console,output

nevech commented 9 years ago

I have the same problem if my store have indexes and used localstorage driver.

Test case:

Returns data without the first operation, but table is populated.

If used indexedDB driver then it work.

yathit commented 9 years ago

Thanks @dave-trudes please update to 1.1.5 for this fix.

@nevech websql and localStorage adaptor are still failing some tests with compound index. I will fix later.