Browse Source

Merge pull request #9971 from nocodb/nc-fix/slt-to-user-type-conversion

fix(nc-gui): trim whitespace while converting from string data type to user
pull/9984/head
Raju Udava 6 days ago committed by GitHub
parent
commit
88f4a866d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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, UITypes.MultiSelect,
].includes(column.uidt) ].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 setStatement = baseUsers
.map((user) => .map((user) =>
sqlClient.knex sqlClient.knex
.raw('WHEN ?? = ? THEN ?', [ .raw(`WHEN ${trimColumn} = ? THEN ?`, [
column.column_name, column.column_name,
user.email, user.email,
user.id, user.id,

Loading…
Cancel
Save