Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong selection when dealing with null values #40

Closed
ghost opened this issue May 1, 2018 · 14 comments
Closed

Wrong selection when dealing with null values #40

ghost opened this issue May 1, 2018 · 14 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented May 1, 2018

Hi again
During development, I found that this query produces a wrong selection:

        {
            From: 'Job',
            Where: {
              jobSuspended_flag: { '!=': 1 },
              state: {
                In: ['Working', 'Diagnostics', 'FinalTest']
              }
            }

The records have the jobSuspended_flag set to 1, but they are selected anyway. There can be two values for this field, 1 or null.

If I change the row to this:

jobSuspended_flag: null

It throws an error:

scripts.bundle.js:3 TypeError: Cannot read property '!=' of null
    at scripts.bundle.js:3
    at Array.every (<anonymous>)
    at e.containsNot (scripts.bundle.js:3)
    at e.addGreatAndLessToNotOp (scripts.bundle.js:3)
    at e.execute (scripts.bundle.js:3)
    at Main.select (scripts.bundle.js:3)
    at Main.executeLogic (scripts.bundle.js:3)
    at Main.checkConnectionAndExecuteLogic (scripts.bundle.js:3)
    at e.executeCodeDirect (scripts.bundle.js:3)
    at e.executeCode (scripts.bundle.js:3)

I'm currently trying to understand JSStore's code in order to debug these problems myself (and maybe posting pull requests), but the way it's structured makes it hard for me. Also there are some type bugs, for example declaring the Promise as any in CodeExecutionHelper.ts makes the compiler angry:

ERROR in node_modules/JsStore/dist/jsstore.d.ts(1051,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'.
src/app/@core/data/db.service.ts(2,26): error TS2306: File '/Users/mc128k/Dropbox/Projects/TRIAD/99 Web Apps/40 TRIAD_Dashboard/node_modules/JsStore/dist/jsstore.d.ts' is not a module.chunk

but the issue here is with the selection. I'm trying to figure out these by myself, just wanted to let you know.

@ghost
Copy link
Author

ghost commented May 1, 2018

By the way, the last error is because the latest build lacks the default export for the .d.ts typescript module, while the production version is ok

@ujjwalguptaofficial
Copy link
Owner

So you are saying that you are getting result with job_suspendedflag:1 right ?

@ghost
Copy link
Author

ghost commented May 1, 2018

Yes, I logged the found records and I see that some have the flag set to 1 (number)

@ujjwalguptaofficial
Copy link
Owner

Ok, I will try to fix this one.

Fyi - I am also working on a project called idbstudio which will help users to debug query and doing lots of things just like others db studio like - sql management studio etc. Also you dont need to log in to see your data, it will print your result in a table like ui.

I just need a little time. Any way i will try to fix these asap.

Thanks.

@ujjwalguptaofficial
Copy link
Owner

Let me know others issue if you found please and any others improvement if you like to include in v2.

Thanks

@ghost
Copy link
Author

ghost commented May 1, 2018

I see that v2 has code that is A LOT better. Good job, this is something I can handle somehow.

@ghost
Copy link
Author

ghost commented May 7, 2018

Installed v2, the problem is here. Here is the query and result set:

query = {
            from: 'Job',
            where: {
              jobSuspended_flag: { '!=': 1 },
              state: {
                in: ['Working', 'Diagnostics', 'FinalTest'],
              },
            },
          };
"[
    {
        "lastEdit": 1524961008,
        "id": "47409D69-2F4F-AA43-8C5E-BD31D4D43423",
        "assignedFutureDTS": "",
        "assignedLabExternalId": "",
        "assignedLabPrimaryId": "017B708F-7876-4814-AAF2-32ACC7833253",
        "assignedLabSecondaryId": "",
        "assignedPartnerId": "",
        "assignedPosId": "36B88F37-0154-4A54-8348-6B351F0620BD",
        "assignedLabPrimaryLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "assignedLabSecondaryLocationId": "",
        "assignedPosLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "clientFullName": ...
        "deviceFullDescription": "Headphones Lightning",
        "deviceCategory": "Audio",
        "deviceFamily": "Headphones",
        "deviceVendor": "Apple",
        "ticket": "002.296",
        "currentDts": "Lab_Primary",
        "state": "Diagnostics",
        "lastAssignedTechnician": ...
        "jobSuspended_flag": 1,
        "dateExpiryEnd": null,
        "dateExpiryStart": 1523484000,
        "dateClosure": null,
        "dateCreation": 1523484000,
        "dateEndJob": null,
        "dateFirstEntryLab1": 1523484000,
        "dateFirstEntryLab2": null,
        "dateLastExitLab1": null,
        "dateLastExitLab2": null,
        "dateStartJob": 1523484000
    },
    {
        "lastEdit": 1525730562,
        "id": "65436136-9F10-654C-BF2A-9F93C865145F",
        "assignedFutureDTS": "",
        "assignedLabExternalId": "",
        "assignedLabPrimaryId": "017B708F-7876-4814-AAF2-32ACC7833253",
        "assignedLabSecondaryId": "",
        "assignedPartnerId": "",
        "assignedPosId": "36B88F37-0154-4A54-8348-6B351F0620BD",
        "assignedLabPrimaryLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "assignedLabSecondaryLocationId": "",
        "assignedPosLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "clientFullName": ...
        "deviceFullDescription": "iPhone 6S",
        "deviceCategory": "Smartphone",
        "deviceFamily": "iPhone",
        "deviceVendor": "Apple",
        "ticket": "003.412",
        "currentDts": "Lab_Primary",
        "state": "Diagnostics",
        "lastAssignedTechnician": ...      "jobSuspended_flag": null,
        "dateExpiryEnd": null,
        "dateExpiryStart": 1525903200,
        "dateClosure": null,
        "dateCreation": 1525471200,
        "dateEndJob": null,
        "dateFirstEntryLab1": 1525471200,
        "dateFirstEntryLab2": null,
        "dateLastExitLab1": null,
        "dateLastExitLab2": null,
        "dateStartJob": 1525471200
    },
    {
        "lastEdit": 1525733359,
        "id": "85E304DE-D3A4-2245-86DC-165FCA0D5C39",
        "assignedFutureDTS": "",
        "assignedLabExternalId": "",
        "assignedLabPrimaryId": "017B708F-7876-4814-AAF2-32ACC7833253",
        "assignedLabSecondaryId": "",
        "assignedPartnerId": "",
        "assignedPosId": "36B88F37-0154-4A54-8348-6B351F0620BD",
        "assignedLabPrimaryLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "assignedLabSecondaryLocationId": "",
        "assignedPosLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "clientFullName": ...
        "deviceFullDescription": "iPad mini (Wi-Fi + Cell)",
        "deviceCategory": "Tablet",
        "deviceFamily": "iPad mini",
        "deviceVendor": "Apple",
        "ticket": "003.401",
        "currentDts": "Lab_Primary",
        "state": "Diagnostics",
        "lastAssignedTechnician": ...      "jobSuspended_flag": null,
        "dateExpiryEnd": null,
        "dateExpiryStart": 1525903200,
        "dateClosure": null,
        "dateCreation": 1525471200,
        "dateEndJob": null,
        "dateFirstEntryLab1": 1525471200,
        "dateFirstEntryLab2": null,
        "dateLastExitLab1": null,
        "dateLastExitLab2": null,
        "dateStartJob": 1525471200
    },
    {
        "lastEdit": 1525752888,
        "id": "91E41DD8-31F2-9B47-BC4C-435776F9834B",
        "assignedFutureDTS": "",
        "assignedLabExternalId": "",
        "assignedLabPrimaryId": "787921DE-AE10-48FE-8D50-FBC2087DA76D",
        "assignedLabSecondaryId": "",
        "assignedPartnerId": "",
        "assignedPosId": "36B88F37-0154-4A54-8348-6B351F0620BD",
        "assignedLabPrimaryLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "assignedLabSecondaryLocationId": "",
        "assignedPosLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "clientFullName": ...
        "deviceFullDescription": "MacBookPro 13\" Retina",
        "deviceCategory": "Computer Portatile",
        "deviceFamily": "MacBookPro",
        "deviceVendor": "Apple",
        "ticket": "003.449",
        "currentDts": "Lab_Primary",
        "state": "Diagnostics",
        "lastAssignedTechnician": ...      "jobSuspended_flag": null,
        "dateExpiryEnd": null,
        "dateExpiryStart": 1525644000,
        "dateClosure": null,
        "dateCreation": 1525471200,
        "dateEndJob": null,
        "dateFirstEntryLab1": 1525471200,
        "dateFirstEntryLab2": null,
        "dateLastExitLab1": null,
        "dateLastExitLab2": null,
        "dateStartJob": 1525644000
    },
    {
        "lastEdit": 1524960987,
        "id": "AA99DC63-77E4-4E4E-BF18-EED15017B70F",
        "assignedFutureDTS": "",
        "assignedLabExternalId": "",
        "assignedLabPrimaryId": "017B708F-7876-4814-AAF2-32ACC7833253",
        "assignedLabSecondaryId": "",
        "assignedPartnerId": "",
        "assignedPosId": "36B88F37-0154-4A54-8348-6B351F0620BD",
        "assignedLabPrimaryLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "assignedLabSecondaryLocationId": "",
        "assignedPosLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "clientFullName": ...
        "deviceFullDescription": "iPhone 6",
        "deviceCategory": "Smartphone",
        "deviceFamily": "iPhone",
        "deviceVendor": "Apple",
        "ticket": "001.193",
        "currentDts": "Lab_Primary",
        "state": "Diagnostics",
        "lastAssignedTechnician": ...
        "jobSuspended_flag": 1,
        "dateExpiryEnd": null,
        "dateExpiryStart": 1521068400,
        "dateClosure": null,
        "dateCreation": 1520809200,
        "dateEndJob": null,
        "dateFirstEntryLab1": 1520809200,
        "dateFirstEntryLab2": null,
        "dateLastExitLab1": null,
        "dateLastExitLab2": null,
        "dateStartJob": 1520809200
    },
    {
        "lastEdit": 1525741018,
        "id": "F931288C-7CA9-484A-B952-2589F4077E54",
        "assignedFutureDTS": "",
        "assignedLabExternalId": "",
        "assignedLabPrimaryId": "787921DE-AE10-48FE-8D50-FBC2087DA76D",
        "assignedLabSecondaryId": "",
        "assignedPartnerId": "",
        "assignedPosId": "36B88F37-0154-4A54-8348-6B351F0620BD",
        "assignedLabPrimaryLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "assignedLabSecondaryLocationId": "",
        "assignedPosLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "clientFullName": ...
        "deviceFullDescription": "MacBookPro 13\"",
        "deviceCategory": "Computer Portatile",
        "deviceFamily": "MacBookPro",
        "deviceVendor": "Apple",
        "ticket": "003.190",
        "currentDts": "Lab_Primary",
        "state": "Diagnostics",
        "lastAssignedTechnician": ...      "jobSuspended_flag": null,
        "dateExpiryEnd": null,
        "dateExpiryStart": 1525644000,
        "dateClosure": null,
        "dateCreation": 1525212000,
        "dateEndJob": null,
        "dateFirstEntryLab1": 1525212000,
        "dateFirstEntryLab2": null,
        "dateLastExitLab1": null,
        "dateLastExitLab2": null,
        "dateStartJob": 1525212000
    },
    {
        "lastEdit": 1525301782,
        "id": "FCA26A9F-8922-F24B-B282-183468482B35",
        "assignedFutureDTS": "",
        "assignedLabExternalId": "",
        "assignedLabPrimaryId": "787921DE-AE10-48FE-8D50-FBC2087DA76D",
        "assignedLabSecondaryId": "",
        "assignedPartnerId": "",
        "assignedPosId": "36B88F37-0154-4A54-8348-6B351F0620BD",
        "assignedLabPrimaryLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "assignedLabSecondaryLocationId": "",
        "assignedPosLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "clientFullName": ...
        "deviceFullDescription": "MacBookPro 13\"",
        "deviceCategory": "Computer Portatile",
        "deviceFamily": "MacBookPro",
        "deviceVendor": "Apple",
        "ticket": "002.634",
        "currentDts": "Lab_Primary",
        "state": "Diagnostics",
        "lastAssignedTechnician": ...
        "jobSuspended_flag": 1,
        "dateExpiryEnd": null,
        "dateExpiryStart": 1524693600,
        "dateClosure": null,
        "dateCreation": 1524261600,
        "dateEndJob": null,
        "dateFirstEntryLab1": 1524261600,
        "dateFirstEntryLab2": null,
        "dateLastExitLab1": null,
        "dateLastExitLab2": null,
        "dateStartJob": 1524434400
    },
    {
        "lastEdit": 1525752109,
        "id": "FDAEFF90-8ADC-9D42-ACDC-33D48BE525DF",
        "assignedFutureDTS": "",
        "assignedLabExternalId": "",
        "assignedLabPrimaryId": "787921DE-AE10-48FE-8D50-FBC2087DA76D",
        "assignedLabSecondaryId": "",
        "assignedPartnerId": "",
        "assignedPosId": "36B88F37-0154-4A54-8348-6B351F0620BD",
        "assignedLabPrimaryLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "assignedLabSecondaryLocationId": "",
        "assignedPosLocationId": "FC35CE4E-517A-4F69-BE4E-BC8D387555F4",
        "clientFullName": ...
        "deviceFullDescription": "MacBookPro 13\"",
        "deviceCategory": "Computer Portatile",
        "deviceFamily": "MacBookPro",
        "deviceVendor": "Apple",
        "ticket": "003.013",
        "currentDts": "Lab_Primary",
        "state": "Diagnostics",
        "lastAssignedTechnician": ...
        "jobSuspended_flag": 0,
        "dateExpiryEnd": null,
        "dateExpiryStart": 1525298400,
        "dateClosure": null,
        "dateCreation": 1524866400,
        "dateEndJob": null,
        "dateFirstEntryLab1": 1524866400,
        "dateFirstEntryLab2": null,
        "dateLastExitLab1": null,
        "dateLastExitLab2": null,
        "dateStartJob": 1524866400
    }
]"

Please ignore the ... in the JSON, it was removed by me because of privacy issues.

Oddly enough, removing the first part of the query makes a difference, the result set includes one more record.

@ghost
Copy link
Author

ghost commented May 13, 2018

I can confirm the issue exists in version 2.0.3

@ujjwalguptaofficial ujjwalguptaofficial self-assigned this May 13, 2018
@ujjwalguptaofficial
Copy link
Owner

@Mc128k - Can you reproduce this for our demo database in idbstudio.? Because all of the test cases I have is for that db only.

You can insert some values or create some table or create another db - just let me know what should I do to reproduce?

Thanks

@ghost
Copy link
Author

ghost commented May 13, 2018

Reproduced successfully. See the attached files for the demo database and the query for the test:

select({
    from: 'Orders',
    where: {
      jobSuspended_flag: {'!=': 1},
      state: {
        in: ['Working', 'Diagnostics', 'FinalTest'],
      },
    },
})

Orders.json.txt

demo_service.ts.txt

The result set includes both orders with flag 0 and 1.

@ujjwalguptaofficial
Copy link
Owner

Ok great. I will fix it within this week.

Thanks

@ujjwalguptaofficial
Copy link
Owner

@Mc128k - issue is resolved in version 2.0.5.Let me know if you are getting this any more.

Thanks.

@ujjwalguptaofficial
Copy link
Owner

ujjwalguptaofficial commented May 16, 2018

Here is the link for testing in idbstudio - https://ujjwalguptaofficial.github.io/idbstudio/?query=select(%7B%0A%20%20%20%20from:%27Employees%27,%0A%20%20%20%20where:%20%7B%0A%20%20%20%20%20%20jobSuspendedFlag:%20%7B%27!=%27:%200%7D,%0A%20%20%20%20%20%20state:%20%7B%0A%20%20%20%20%20%20%20%20in:%20%5B%27Working%27,%20%27Diagnostics%27,%20%27FinalTest%27%5D,%0A%20%20%20%20%20%20%7D,%0A%20%20%20%20%7D%0A%7D)&db=Demo

When it says column - jobSuspendedLog doesn't exist which means that you have old db created. Please drop the database by calling - dropDb() in another tab and reload the page. It should work.

Thanks

@ghost
Copy link
Author

ghost commented May 16, 2018

Indeed it seems to be working! Thanks a lot!!

@ghost ghost closed this as completed May 16, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant