### What? Improves the flattening logic used in the import-export plugin to correctly handle polymorphic relationships (both `hasOne` and `hasMany`) when generating CSV columns. ### Why? Previously, `hasMany` polymorphic relationships would flatten their full `value` object recursively, resulting in unwanted keys like `createdAt`, `title`, `email`, etc. This change ensures that only the `id` and `relationTo` fields are included, matching how `hasOne` polymorphic fields already behave. ### How? - Updated `flattenObject` to special-case `hasMany` polymorphic relationships and extract only `relationTo` and `id` per index. - Refined `getFlattenedFieldKeys` to return correct column keys for polymorphic fields: - `hasMany polymorphic → name_0_relationTo`, `name_0_id` - `hasOne polymorphic → name_relationTo`, `name_id` - `monomorphic → name` or `name_0` - **Added try/catch blocks** around `toCSVFunctions` calls in `flattenObject`, with descriptive error messages including the column path and input value. This improves debuggability if a custom `toCSV` function throws.
Payload Import/Export Plugin
A plugin for Payload to easily import and export data.