feat: Add support for dot notation on array fields of Parse Object (#9115)

This commit is contained in:
Diamond Lewis
2024-07-08 16:29:58 -05:00
committed by GitHub
parent 892052cc44
commit cf4c8807b9
4 changed files with 90 additions and 4 deletions

View File

@@ -175,6 +175,8 @@ const toPostgresSchema = schema => {
return schema;
};
const isArrayIndex = (arrayIndex) => Array.from(arrayIndex).every(c => c >= '0' && c <= '9');
const handleDotFields = object => {
Object.keys(object).forEach(fieldName => {
if (fieldName.indexOf('.') > -1) {
@@ -207,7 +209,11 @@ const transformDotFieldToComponents = fieldName => {
if (index === 0) {
return `"${cmpt}"`;
}
return `'${cmpt}'`;
if (isArrayIndex(cmpt)) {
return Number(cmpt);
} else {
return `'${cmpt}'`;
}
});
};