-
Notifications
You must be signed in to change notification settings - Fork 48
Description
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:
Nano-SQL/packages/Core/src/utilities.ts
Line 437 in af74705
| 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",