lautr / strapi-plugin-duplicate-button

19 stars 8 forks source link

Doesn't work with components / dynamic zone: returning "id" - duplicate key value violates unique constraint "files_related_morphs_pkey" #24

Closed JannikZed closed 5 months ago

JannikZed commented 8 months ago

I was just trying out the duplicate button, as I wanted to duplicate a whole page including several components and their content. I receive a long error in Strapi:

error: insert into "public"."files_related_morphs" ("field", "file_id", "order", "related_id", "related_type") values ($1, $2, $3, $4, $5), ($6, $7, $8, $9, $10), ($11, $12, $13, $14, $15), ($16, $17, $18, $19, $20), ($21, $22, $23, $24, $25), ($26, $27, $28, $29, $30), ($31, $32, $33, $34, $35), ($36, $37, $38, $39, $40), ($41, $42, $43, $44, $45), ($46, $47, $48, $49, $50), ($51, $52, $53, $54, $55), ($56, $57, $58, $59, $60), ($61, $62, $63, $64, $65), ($66, $67, $68, $69, $70), ($71, $72, $73, $74, $75), ($76, $77, $78, $79, $80), ($81, $82, $83, $84, $85), ($86, $87, $88, $89, $90), ($91, $92, $93, $94, $95), ($96, $97, $98, $99, $100) returning "id" - duplicate key value violates unique constraint "files_related_morphs_pkey"
error: insert into "public"."files_related_morphs" ("field", "file_id", "order", "related_id", "related_type") values ($1, $2, $3, $4, $5), ($6, $7, $8, $9, $10), ($11, $12, $13, $14, $15), ($16, $17, $18, $19, $20), ($21, $22, $23, $24, $25), ($26, $27, $28, $29, $30), ($31, $32, $33, $34, $35), ($36, $37, $38, $39, $40), ($41, $42, $43, $44, $45), ($46, $47, $48, $49, $50), ($51, $52, $53, $54, $55), ($56, $57, $58, $59, $60), ($61, $62, $63, $64, $65), ($66, $67, $68, $69, $70), ($71, $72, $73, $74, $75), ($76, $77, $78, $79, $80), ($81, $82, $83, $84, $85), ($86, $87, $88, $89, $90), ($91, $92, $93, $94, $95), ($96, $97, $98, $99, $100) returning "id" - duplicate key value violates unique constraint "files_related_morphs_pkey"

that is most likely related to components ? I don't know exactly what needs to be done to support cloning of content in dynamic zones, but I would love to see that being supported (and again wondering how this isn't a native strapi feature)

denitsa9006 commented 5 months ago

Hey team, We have an issue with the duplicate button.

{ "data": null, "error": { "status": 400, "name": "BadRequestError", "message": "Entity could not be cloned as it has unique and/or relational fields. Please edit those fields manually and save to complete the cloning.", "details": { "prohibitedFields": [ [ [ "slug" ], "unique" ] ] } } }

lautr commented 5 months ago

hi

@denitsa9006 & @JannikZed

Can you check if this error also occurs when using the duplicate function from the list view? If so then its an issue with the underlying logic inside strapi, if it only happens from the duplicate button it would be helpful to have some code to reproduce it i could check.

denitsa9006 commented 5 months ago

I can confirm that this issue happens on both the list view and the edit functionality. We have reverted the bumped version of the plugin and this returned the functionality back to normal.

I am heavy user of strapi content manager but not a developer- would consult our team that works with strapi and we can perhaps give you more information about the error - just let me know what you need.

On Fri, 7 Jun 2024 at 13:58, Johannes Lauter @.***> wrote:

hi

@denitsa9006 https://github.com/denitsa9006 & @JannikZed https://github.com/JannikZed

Can you check if this error also occurs when using the duplicate function from the list view? If so then its an issue with the underlying logic inside strapi, if it only happens from the duplicate button it would be helpful to have some code to reproduce it i could check.

— Reply to this email directly, view it on GitHub https://github.com/lautr/strapi-plugin-duplicate-button/issues/24#issuecomment-2154599537, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIAZF5I4E2VMY24S3BOGH3DZGGG6NAVCNFSM6AAAAABI6FVQ4WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJUGU4TSNJTG4 . You are receiving this because you were mentioned.Message ID: @.***>

sushmavoleti commented 5 months ago

Below PR is causing such issues. Reverting it solves the problem https://github.com/lautr/strapi-plugin-duplicate-button/pull/27

lautr commented 5 months ago

I reverted the PR for now, i created an issue to better align strapi internal copy logic.