Giter Site home page Giter Site logo

Comments (4)

dfahlander avatar dfahlander commented on September 7, 2024

Don't think the number of indexes are any problems. I'll do a unit test to
reproduce it next week (holiday right now). Did you miss to index 'age' or
is it just a typo? Do you get any error if adding a final .catch() at the
end?
Den 24 jul 2014 17:35 skrev "salles" [email protected]:

hi, just wanted to check wether i am doing something wrong to get such
"unstable" results.

i have played with dexie on top of Chrome and FFOS, as well as the webview
on Android 4.1.2 up to 4.4 Kitkat, and on all of them the results of a
query like below

     db.phones.where('name').startsWithIgnoreCase('moto'));

it seems to increase the occurrence, and even not responding at all when
the OR clause is included in the query chain.

        db.phones.where('name').startsWithIgnoreCase('moto')).or('age').below('10'));

the only creepy thing i have done was creating a lot of indexes...(14) too
much ?

    var dbi = new Dexie("MyDB");
    dbi.version(1).stores({
        phones: "++id, additionalFeatures, android, availability, battery, camera, connectivity, description, display, hardware, id, images, name, sizeAndWeight, storage"
    });


Reply to this email directly or view it on GitHub
#15.

from dexie.js.

dfahlander avatar dfahlander commented on September 7, 2024

Could you describe how it increases the occurrence? Are you using toArray () or each() to get the results? The or method may (and usually does) produce the results in random order, but should never give different results.

If you have a chance to provide a sample code and data to reproduce it that would be very helpful.

Thanks,
David

from dexie.js.

dfahlander avatar dfahlander commented on September 7, 2024

I could not reproduce the error. I replaced "age" with "id" to make the query on a registered index. Otherwise the query would fail each time with "NotFoundError" becuase the index "age" wasn't found. When using an existing index I always get the same results. I've tested in Chrome 36.0.1985.125, Opera 22.0.1471.70, Firefox 30 and IE11.

I belive your error could be due to an error from an earlier write operaion you've made and did not wait for to finish. Check what happens if you catch your write operations performed prior to executing your or() query. When you start your query using the or() operation, the earlier write operation has not yet failed. When it fails, one of the or() parts will fail with the real error and the other with an "AbortError". Which one that gets the first error may vary. If you catch your or() operation you may get the actual error, or the AbortError. But the best thing is to catch the earlier write operations to see where they fail. These are my guesses and only a therory since I could not reproduce the error.

In my test, I could execute 10 simiultanous queries with the or() method applied, as well as executing the in sequence. Each time I run the unit test I get the same results. Here's the code:

asyncTest("or-issue#15-test", function () {
    var db = new Dexie("MyDB_issue15");
    db.version(1).stores({
        phones: "++id, additionalFeatures, android, availability, battery, camera, connectivity, description, display, hardware, id, images, name, sizeAndWeight, storage"
    });
    db.on('populate', function () {
        ok(true, "on(populate) called");
        for (var i = 0; i < 100; ++i) {
            db.phones.add({ name: "Name" + randomString(16), additionalFeatures: [randomString(10)], android: 1, availability: 0, battery: 1, camera: 1 });
        }

        function randomString(count) {
            var ms = [];
            for (var i = 0; i < count; ++i) {
                ms.push(String.fromCharCode(32 + Math.floor(Math.random() * 96)));
            }
            return ms.join('');
        }
    });

    db.open().catch(function (err) {
        ok(false, "DB ERROR: " + err);
    });


    var numRuns = 10;

    for (var i = 0; i < numRuns; ++i) {

        db.phones.where("name").startsWithIgnoreCase("name").or("id").below(50).toArray(function (a) {

            equal(a.length, 100, "Found 100 phones");

        }).catch(function (err) {

            ok(false, "error:" + err);

        }).finally(function () {
            if (--numRuns == 0) {
                // All test runs finished. Delete DB and exit unit test.
                db.delete();
                start();
            }
        });
    }

});

If you have some code to reproduce the error, your welcome and I will debug it for you, otherwise I will close this issue within some days.

Thanks,
David

from dexie.js.

sallespro avatar sallespro commented on September 7, 2024

hi, thanks for your detailed analysis and commitment to help !

i have indeed missed the 'age' indexing which might have been the source of the problem.

from dexie.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.