1
0
Fork 0
mirror of synced 2024-08-09 15:17:57 +12:00

Allow null strings (#12298)

* Allow null strings

* Don't update null to blank

* Save empty as null

* Make blank string map to null

* Add mappings for BigInt

* Fix unit tests
This commit is contained in:
melohagan 2023-11-23 09:53:35 +00:00 committed by GitHub
parent 778104d6e6
commit 0e93717f1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View file

@ -426,7 +426,7 @@ describe.each([
const saved = (await loadRow(id, table._id!)).body const saved = (await loadRow(id, table._id!)).body
expect(saved.stringUndefined).toBe(undefined) expect(saved.stringUndefined).toBe(undefined)
expect(saved.stringNull).toBe("") expect(saved.stringNull).toBe(null)
expect(saved.stringString).toBe("i am a string") expect(saved.stringString).toBe("i am a string")
expect(saved.numberEmptyString).toBe(null) expect(saved.numberEmptyString).toBe(null)
expect(saved.numberNull).toBe(null) expect(saved.numberNull).toBe(null)

View file

@ -46,23 +46,23 @@ export const TYPE_TRANSFORM_MAP: any = {
parse: parseArrayString, parse: parseArrayString,
}, },
[FieldTypes.STRING]: { [FieldTypes.STRING]: {
"": "", "": null,
[null]: "", [null]: null,
[undefined]: undefined, [undefined]: undefined,
}, },
[FieldTypes.BARCODEQR]: { [FieldTypes.BARCODEQR]: {
"": "", "": null,
[null]: "", [null]: null,
[undefined]: undefined, [undefined]: undefined,
}, },
[FieldTypes.FORMULA]: { [FieldTypes.FORMULA]: {
"": "", "": null,
[null]: "", [null]: null,
[undefined]: undefined, [undefined]: undefined,
}, },
[FieldTypes.LONGFORM]: { [FieldTypes.LONGFORM]: {
"": "", "": null,
[null]: "", [null]: null,
[undefined]: undefined, [undefined]: undefined,
}, },
[FieldTypes.NUMBER]: { [FieldTypes.NUMBER]: {
@ -71,6 +71,11 @@ export const TYPE_TRANSFORM_MAP: any = {
[undefined]: undefined, [undefined]: undefined,
parse: n => parseFloat(n), parse: n => parseFloat(n),
}, },
[FieldTypes.BIGINT]: {
"": null,
[null]: null,
[undefined]: undefined,
},
[FieldTypes.DATETIME]: { [FieldTypes.DATETIME]: {
"": null, "": null,
[undefined]: undefined, [undefined]: undefined,