From 1cfbdb2e83d1802c2500cd4640fa7b48a8afe662 Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 15 Oct 2022 16:33:48 +0300 Subject: [PATCH] fix: handle more than 64 options for mysql Signed-off-by: mertmit --- packages/nocodb/src/lib/meta/api/columnApis.ts | 12 ++++++++++++ .../nocodb/src/lib/meta/api/sync/helpers/job.ts | 14 +++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/columnApis.ts b/packages/nocodb/src/lib/meta/api/columnApis.ts index f6e86d0967..883ed17cc3 100644 --- a/packages/nocodb/src/lib/meta/api/columnApis.ts +++ b/packages/nocodb/src/lib/meta/api/columnApis.ts @@ -605,6 +605,12 @@ export async function columnAdd(req: Request, res: Response) { ) { colBody.dtxp = "''"; } + + if (colBody.dt === 'set') { + if (colBody.colOptions?.options.length > 64) { + colBody.dt = 'text'; + } + } } } @@ -901,6 +907,12 @@ export async function columnUpdate(req: Request, res: Response) { ) { colBody.dtxp = "''"; } + + if (colBody.dt === 'set') { + if (colBody.colOptions?.options.length > 64) { + colBody.dt = 'text'; + } + } } // Handle option delete diff --git a/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts b/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts index 090d54a274..39202e609b 100644 --- a/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts +++ b/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts @@ -577,11 +577,15 @@ export default async ( ncCol.colOptions = { options: [...colOptions.data], }; - // if options are empty, configure '' as default option - ncCol.dtxp = - colOptions.data - .map((el) => `'${el.title.replace(/'/gi, "''")}'`) - .join(',') || "''"; + + if (['mysql', 'mysql2'].includes(getRootDbType())) { + // if options are empty, configure '' as an option + ncCol.dtxp = + colOptions.data + .map((el) => `'${el.title.replace(/'/gi, "''")}'`) + .join(',') || "''"; + } + break; case undefined: break;