|
|
@ -148,10 +148,15 @@ export async function tableCreate(req: Request<any, any, TableReqType>, res) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const sqlMgr = await ProjectMgrv2.getSqlMgr(project); |
|
|
|
const sqlMgr = await ProjectMgrv2.getSqlMgr(project); |
|
|
|
|
|
|
|
|
|
|
|
const sqlClient = await NcConnectionMgrv2.getSqlClient(base); |
|
|
|
const sqlClient = await NcConnectionMgrv2.getSqlClient(base); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dbDriver = NcConnectionMgrv2.get(base); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const sqlClientType = dbDriver.clientType(); |
|
|
|
|
|
|
|
|
|
|
|
let tableNameLengthLimit = 255; |
|
|
|
let tableNameLengthLimit = 255; |
|
|
|
const sqlClientType = sqlClient.clientType; |
|
|
|
|
|
|
|
if (sqlClientType === 'mysql2' || sqlClientType === 'mysql') { |
|
|
|
if (sqlClientType === 'mysql2' || sqlClientType === 'mysql') { |
|
|
|
tableNameLengthLimit = 64; |
|
|
|
tableNameLengthLimit = 64; |
|
|
|
} else if (sqlClientType === 'pg') { |
|
|
|
} else if (sqlClientType === 'pg') { |
|
|
@ -164,6 +169,16 @@ export async function tableCreate(req: Request<any, any, TableReqType>, res) { |
|
|
|
NcError.badRequest(`Table name exceeds ${tableNameLengthLimit} characters`); |
|
|
|
NcError.badRequest(`Table name exceeds ${tableNameLengthLimit} characters`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const mxColumnLength = Column.getMaxColumnNameLength(sqlClientType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const column of req.body.columns) { |
|
|
|
|
|
|
|
if (column.column_name.length > mxColumnLength) { |
|
|
|
|
|
|
|
NcError.badRequest( |
|
|
|
|
|
|
|
`Column name ${column.column_name} exceeds ${mxColumnLength} characters` |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
req.body.columns = req.body.columns?.map((c) => ({ |
|
|
|
req.body.columns = req.body.columns?.map((c) => ({ |
|
|
|
...getColumnPropsFromUIDT(c as any, base), |
|
|
|
...getColumnPropsFromUIDT(c as any, base), |
|
|
|
cn: c.column_name, |
|
|
|
cn: c.column_name, |
|
|
|