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

Selection of date types with undefined values #219

Open
murphy85 opened this issue May 6, 2022 · 0 comments
Open

Selection of date types with undefined values #219

murphy85 opened this issue May 6, 2022 · 0 comments

Comments

@murphy85
Copy link

murphy85 commented May 6, 2022

It is not possible to select values with type date, if the value is undefined.

On selection the mutateRowTypes function is called. In this function columns with type date will be converter to ISOString on selection: new Date(useObj[m.key]).toISOString();

If useObj[m.key] returns undefined, an error is thrown: RangeError: Invalid Date

See:

useObj[m.key] = new Date(useObj[m.key]).toISOString();

Is there a reason why an ISODate is returned instead of Date type? I think there should be a conversion to ISODate on insert and a conversion to Date on select.

If I'm wrong, please insert an undefined check before using new Date()

Meanwhile I will try to use a "custom type" handling

            types: {
                "date": {
                    onInsert: (colValue) => colValue ? new Date(colValue).toISOString() : undefined,
                    onSelect: (colValue) => colValue ? new Date(colValue) : undefined
                }
            }

(Btw: The interface describes onInsert and onSelect, but I cannot find any use of onInsert?)

Im using nanosql with IndexedDB
"@nano-sql/core": "^2.3.7",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant