ujjwalguptaofficial / JsStore

Simplifying IndexedDB with SQL like syntax and promises
http://jsstore.net/
MIT License
858 stars 110 forks source link

Left Join & 'as' option #124

Closed olintononthemovesw closed 5 years ago

olintononthemovesw commented 5 years ago

When performing a left join, there is an error when applying an 'as' option Example (https://ujjwalguptaofficial.github.io/idbstudio/?db=Demo) Initialise with:

update({
    in: "Orders",
    set: {
        shipperId: 1234567890
    },
    where: {
        orderId: 10248
    }
});

Then:

select({
    from: "Orders",
    join: {
        with: "Shippers",
        on: "Shippers.shipperId = Orders.shipperId",
        type: "left"
    }
});

will correctly return the the records... image

But...

select({
    from: "Orders",
    join: {
        with: "Shippers",
        on: "Shippers.shipperId = Orders.shipperId",
        as: {
            shipperId: "Shippers.shipperId",
            shipperName: "Shippers.shipperName",
            phone: "Shippers.phone"
        },
        type: "left"
    }
});

Will not apply the alternative field names, as well as resulting in undefined field values. image

ujjwalguptaofficial commented 5 years ago

Issue fixed in v - 3.3.6. Please test and let me know.

Fyi - We are also putting different test case to ensure this doesn't happen again.

olintononthemovesw commented 5 years ago

Tested. For the most parts this is now working. Thank you!

We have however found an edge case when applying an 'as' statement... https://github.com/ujjwalguptaofficial/JsStore/issues/125