Skip to content

Commit d0bb431

Browse files
authored
fix(validate-types): resolve attr type changed to number when is bigint
1 parent 90f7013 commit d0bb431

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/__tests__/validateTypes.unit.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,16 @@ describe('validateTypes', () => {
169169
})
170170

171171
it('converts arrays of bigints to sets', async () => {
172-
const result = validateTypes()({ type: 'set', setType: 'bigint' }, 'attr', [
172+
const attr = { type: 'set', setType: 'bigint' }
173+
const result = validateTypes()(attr, 'attr', [
173174
BigInt(-1234),
174175
BigInt('123000000000000000000001')
175176
])
176177
expect(result).toEqual(new Set([
177178
toDynamoBigInt(BigInt(-1234)),
178179
toDynamoBigInt(BigInt('123000000000000000000001'))
179180
]))
181+
// Should not mutate the attribute
182+
expect(attr.setType).toEqual('bigint')
180183
})
181184
})

src/lib/validateTypes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export default () => (mapping: any, field: any, value: any) => {
6161
if (value instanceof Set) {
6262

6363
if (mapping.setType === 'bigint') {
64-
mapping.setType = 'number'
6564
value = Array.from(value).map((n) => toDynamoBigInt(n))
6665
}
6766

@@ -78,7 +77,6 @@ export default () => (mapping: any, field: any, value: any) => {
7877
const actualSetType = typeOf(value[0])?.toLowerCase?.()
7978

8079
if (mapping.setType === 'bigint') {
81-
mapping.setType = 'number'
8280
value = value.map((n) => toDynamoBigInt(n))
8381
}
8482

0 commit comments

Comments
 (0)