Browse Source

fix(nocodb): add case when for AND and OR in MSSQL fn

pull/4644/head
Wing-Kam Wong 2 years ago
parent
commit
f584211eaa
  1. 24
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/mssql.ts

24
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/mssql.ts

@ -123,6 +123,30 @@ const mssql = {
)} % 7 + 7) % 7 ${colAlias}` )} % 7 + 7) % 7 ${colAlias}`
); );
}, },
AND: (args: MapFnArgs) => {
return args.knex.raw(
`CASE WHEN ${args.knex
.raw(
`${args.pt.arguments
.map((ar) => args.fn(ar, '', 'AND').toQuery())
.join(' AND ')}`
)
.wrap('(', ')')
.toQuery()} THEN 1 ELSE 0 END ${args.colAlias}`
);
},
OR: (args: MapFnArgs) => {
return args.knex.raw(
`CASE WHEN ${args.knex
.raw(
`${args.pt.arguments
.map((ar) => args.fn(ar, '', 'OR').toQuery())
.join(' OR ')}`
)
.wrap('(', ')')
.toQuery()} THEN 1 ELSE 0 END ${args.colAlias}`
);
},
}; };
export default mssql; export default mssql;

Loading…
Cancel
Save