Browse Source

fix: add missing default value handler for select types

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3082/head
mertmit 2 years ago
parent
commit
ca50f7d396
  1. 23
      packages/nocodb/src/lib/meta/api/columnApis.ts

23
packages/nocodb/src/lib/meta/api/columnApis.ts

@ -764,16 +764,21 @@ export async function columnUpdate(req: Request, res: Response<TableType>) {
}
// Handle default values
const optionTitles = colBody.colOptions.options.map(el => el.title);
if (colBody.cdf) {
if (driverType === 'mysql' || driverType === 'mysql2') {
} else if (driverType === 'pg') {
} else if (driverType === 'mssql') {
} else if (driverType === 'sqlite3') {
if (colBody.uidt === UITypes.SingleSelect) {
if (!optionTitles.includes(colBody.cdf)) {
NcError.badRequest(`Default value '${colBody.cdf}' is not a select option.`);
}
} else {
for (const cdf of colBody.cdf.split(',')) {
if (!optionTitles.includes(cdf)) {
NcError.badRequest(`Default value '${cdf}' is not a select option.`);
}
}
}
if (driverType === 'pg') {
colBody.cdf = `'${colBody.cdf}'`;
}
}

Loading…
Cancel
Save