{"record":{"id":"687b9fb7b6f73474","repo":"payloadcms/payload","slug":"not-supported","errorCode":null,"errorMessage":"Not supported","messagePattern":"Not supported","errorType":"http","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"packages/drizzle/src/queries/getTableColumnFromPath.ts","lineNumber":369,"sourceCode":"          constraintPath: `${constraintPath}${field.name}.`,\n          constraints,\n          fields: field.flattenedFields,\n          joins,\n          locale,\n          parentIsLocalized: parentIsLocalized || field.localized,\n          pathSegments: pathSegments.slice(1),\n          rootTableName,\n          selectFields,\n          selectLocale,\n          tableName: newTableName,\n          tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,\n          value,\n        })\n      }\n\n      case 'join': {\n        if (Array.isArray(field.collection)) {\n          throw new APIError('Not supported')\n        }\n\n        const newCollectionPath = pathSegments.slice(1).join('.')\n\n        if (field.hasMany) {\n          const relationTableName = `${adapter.tableNameMap.get(toSnakeCase(field.collection))}${adapter.relationshipsSuffix}`\n\n          const existingTable = joins.find(\n            (e) => e.queryPath === `${constraintPath}${field.name}._rels`,\n          )\n\n          const aliasRelationshipTable = (existingTable?.table ??\n            getTableAlias({\n              adapter,\n              tableName: relationTableName,\n            }).newAliasTable) as PgTableWithColumns<any>\n\n          const relationshipField = getFieldByPath({","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/drizzle/src/queries/getTableColumnFromPath.ts#L351-L387","documentation":"`APIError('Not supported')` from the `join` field case in `getTableColumnFromPath`: the code path that turns a join field into a SQL join rejects polymorphic joins, i.e. when `field.collection` is an array (the join points to one of several collections selectable per row). The Drizzle query builder does not implement cross-collection polymorphic joins for this traversal, so it refuses rather than produce wrong SQL.","triggerScenarios":"Querying (`where` or `select`) through a join-type field whose `collection` is an array of allowed collections, e.g. a blocks/join field that can reference multiple collections, by a path that requires traversing the join.","commonSituations":"A `join` field configured with multiple target collections; querying a polymorphic relationship/join by a deep path; a UI or API query autogenerated for a polymorphic join field.","solutions":["Avoid deep-path queries through polymorphic (`collection: [...]`) join fields; restructure the query to filter on the target collections directly.","If you control the schema, narrow the join field to a single `collection` so a concrete join is possible.","Perform the filter in application logic by fetching and post-filtering."],"exampleFix":"// before: join field 'related' allows ['posts','pages']\nawait payload.find({ collection: 'sections', where: { 'related.title': { contains: 'x' } } })\n// after: query each target collection, or restrict the join to one collection\n//   join: { name: 'related', collection: 'posts' }","handlingStrategy":"validation","validationCode":"// Avoid deep-path queries through polymorphic join fields\nfunction isPolymorphicJoin(field) {\n  return field?.type === 'join' && Array.isArray(field.collection)\n}\nconst targetField = payload.collections[collection].config.flattenedFields[seg]\nif (isPolymorphicJoin(targetField)) {\n  throw new Error(`Cannot query through polymorphic join '${seg}'; query target collections directly.`)\n}","typeGuard":"const isPolymorphicJoinField = (f): boolean => f?.type === 'join' && Array.isArray(f?.collection)","tryCatchPattern":"try {\n  await payload.find({ collection, where })\n} catch (err) {\n  if (err?.statusCode === 400 && err?.message === 'Not supported') {\n    return res.status(400).json({ error: 'Querying this polymorphic join path is not supported.' })\n  }\n  throw err\n}","preventionTips":["Restrict join fields to a single collection when deep filtering is required.","Filter target collections directly instead of traversing polymorphic joins.","Validate API query input against the field schema before issuing the query."],"tags":["query","relationships","polymorphic","join","unsupported"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}