Skip to content

Commit

Permalink
chore(db-postgres): fix localized relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRibbens committed May 26, 2024
1 parent 0c2fd92 commit 6764ec6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/db-postgres/src/schema/traverseFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,10 @@ export const traverseFields = ({
if (!disableNotNull && field.required && !field.admin?.condition) {
targetTable[fieldName].notNull()
}
break
}
if (adapter.payload.config.localization && field.localized) {
hasLocalizedRelationshipField = true
}

break
Expand Down
3 changes: 2 additions & 1 deletion packages/db-postgres/src/transform/read/traverseFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export const traverseFields = <T extends Record<string, unknown>>({
}

if (field.type === 'relationship' || field.type === 'upload') {
if (!('hasMany' in field) || (!field.hasMany && field.relationTo === 'string')) {
if (typeof field.relationTo === 'string' && !('hasMany' in field && field.hasMany)) {
if (
field.localized &&
config.localization &&
Expand Down Expand Up @@ -317,6 +317,7 @@ export const traverseFields = <T extends Record<string, unknown>>({
const relationsByLocale: Record<string, Record<string, unknown>[]> = {}

relationPathMatch.forEach((row) => {
// TODO: the row.locale is not defined
if (typeof row.locale === 'string') {
if (!relationsByLocale[row.locale]) relationsByLocale[row.locale] = []
relationsByLocale[row.locale].push(row)
Expand Down

0 comments on commit 6764ec6

Please sign in to comment.