mirror of
https://github.com/logto-io/logto.git
synced 2025-02-17 22:04:19 -05:00
feat(core): save empty string as null value in DB (#1901)
This commit is contained in:
parent
f9879df7bd
commit
ecdf06ef39
2 changed files with 13 additions and 1 deletions
|
@ -53,6 +53,10 @@ describe('convertToPrimitiveOrSql()', () => {
|
|||
expect(convertToPrimitiveOrSql(normalKey, ['bar'])).toEqual('["bar"]');
|
||||
});
|
||||
|
||||
it('converts empty string to null value', () => {
|
||||
expect(convertToPrimitiveOrSql(normalKey, '')).toEqual(null);
|
||||
});
|
||||
|
||||
it('converts value to sql when key ends with special set and value is number', () => {
|
||||
for (const value of timestampKeyEndings) {
|
||||
expect(convertToPrimitiveOrSql(`${normalKey}${value}`, 12_341_234)).toEqual({
|
||||
|
|
|
@ -47,7 +47,15 @@ export const convertToPrimitiveOrSql = (
|
|||
return sql`to_timestamp(${value}::double precision / 1000)`;
|
||||
}
|
||||
|
||||
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
||||
if (typeof value === 'number' || typeof value === 'boolean') {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (typeof value === 'string') {
|
||||
if (value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue