Browse Source

fix(nc-gui): trim whitespace while converting from string data type to user

pull/9971/head
Ramesh Mane 7 days ago
parent
commit
c2814150d1
  1. 18
      packages/nocodb/src/services/columns.service.ts

18
packages/nocodb/src/services/columns.service.ts

@ -1483,10 +1483,26 @@ export class ColumnsService {
UITypes.MultiSelect,
].includes(column.uidt)
) {
const dbDriver = await reuseOrSave('dbDriver', reuse, async () =>
NcConnectionMgrv2.get(source),
);
const driverType = dbDriver.clientType();
let trimColumn = `??`;
if (driverType === 'mysql' || driverType === 'mysql2') {
trimColumn = `TRIM(BOTH ' ' FROM ??)`;
} else if (driverType === 'pg') {
trimColumn = `BTRIM(??)`;
} else if (driverType === 'mssql') {
trimColumn = `LTRIM(RTRIM(??))`;
} else if (driverType === 'sqlite3') {
trimColumn = `TRIM(??)`;
}
setStatement = baseUsers
.map((user) =>
sqlClient.knex
.raw('WHEN ?? = ? THEN ?', [
.raw(`WHEN ${trimColumn} = ? THEN ?`, [
column.column_name,
user.email,
user.id,

Loading…
Cancel
Save