Skip to content

Commit d5e58f2

Browse files
authored
fix: handle empty strings (#103)
1 parent aeadcf2 commit d5e58f2

File tree

6 files changed

+471
-1
lines changed

6 files changed

+471
-1
lines changed

api/lib/get-fields-update-query-and-fields.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ const READ_ONLY_FIELDS = [
3636
* @returns {{query: string, fields: Record<string, string>}}
3737
*/
3838
export function getFieldsUpdateQueryAndFields(state, fields) {
39+
// When updating fields convert empty strings to null to ensure that the field's value
40+
// is correctly unset. This is important for date fields, which fail validation if
41+
// an empty string is passed.
3942
const existingFields = Object.fromEntries(
4043
Object.keys(fields)
4144
.filter((key) => state.fields[key].existsInProject)
42-
.map((key) => [key, fields[key]])
45+
.map((key) => [key, fields[key] === "" ? null : fields[key]])
4346
);
4447

4548
const readOnlyFields = Object.keys(existingFields)

0 commit comments

Comments
 (0)