Browse Source

feat(nocodb): validate column name length in columnUpdate

pull/5131/head
Wing-Kam Wong 2 years ago
parent
commit
2a1abc1acd
  1. 13
      packages/nocodb/src/lib/meta/api/columnApis.ts

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

@ -652,8 +652,21 @@ export async function columnUpdate(req: Request, res: Response<TableType>) {
const table = await Model.getWithInfo({ const table = await Model.getWithInfo({
id: column.fk_model_id, id: column.fk_model_id,
}); });
const base = await Base.get(table.base_id); const base = await Base.get(table.base_id);
const dbDriver = NcConnectionMgrv2.get(base);
const sqlClientType = dbDriver.clientType();
const mxColumnLength = Column.getMaxColumnNameLength(sqlClientType);
if (req.body.column_name.length > mxColumnLength) {
NcError.badRequest(
`Column name ${req.body.column_name} exceeds ${mxColumnLength} characters`
);
}
if ( if (
!isVirtualCol(req.body) && !isVirtualCol(req.body) &&
!(await Column.checkTitleAvailable({ !(await Column.checkTitleAvailable({

Loading…
Cancel
Save