Skip to content

Commit

Permalink
fix(db-postgres): Fixes nested groups inside nested blocks (#5882)
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
  • Loading branch information
rfdomingues98 and DanRibbens committed Apr 21, 2024
1 parent 985796b commit e258866
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ const getFlattenedFieldNames = (
}

if (fieldHasSubFields(field)) {
fieldPrefix = 'name' in field ? `${prefix}${field.name}.` : prefix
fieldPrefix = 'name' in field ? `${prefix}${field.name}_` : prefix
return [...fieldsToUse, ...getFlattenedFieldNames(field.fields, fieldPrefix)]
}

if (field.type === 'tabs') {
return [
...fieldsToUse,
...field.tabs.reduce((tabFields, tab) => {
fieldPrefix = 'name' in tab ? `${prefix}.${tab.name}` : prefix
fieldPrefix = 'name' in tab ? `${prefix}_${tab.name}` : prefix
return [
...tabFields,
...(tabHasName(tab)
Expand All @@ -51,7 +51,7 @@ const getFlattenedFieldNames = (
return [
...fieldsToUse,
{
name: `${fieldPrefix?.replace('.', '_') || ''}${field.name}`,
name: `${fieldPrefix}${field.name}`,
localized: field.localized,
},
]
Expand Down Expand Up @@ -84,7 +84,11 @@ export const validateExistingBlockIsIdentical = ({

if (missingField) {
throw new InvalidConfiguration(
`The table ${rootTableName} has multiple blocks with slug ${block.slug}, but the schemas do not match. One block includes the field ${typeof missingField === 'string' ? missingField : missingField.name}, while the other block does not.`,
`The table ${rootTableName} has multiple blocks with slug ${
block.slug
}, but the schemas do not match. One block includes the field ${
typeof missingField === 'string' ? missingField : missingField.name
}, while the other block does not.`,
)
}

Expand Down

0 comments on commit e258866

Please sign in to comment.