Browse Source

fix: add client type in custom knex

Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>
pull/1156/head
Wing-Kam Wong 3 years ago
parent
commit
60b793a6fb
  1. 5
      packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts

5
packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts

@ -92,9 +92,10 @@ const appendWhereCondition = function(
knexRef,
isHaving = false
) {
const clientType = knexRef?.client?.config?.client;
const opMapping = {
...opMappingGen,
...(knexRef?.client?.config?.client === 'pg' ? { like: 'ilike' } : {})
...(clientType === 'pg' ? { like: 'ilike' } : {})
};
const camKey = isHaving ? 'Having' : 'Where';
const key = isHaving ? 'having' : 'where';
@ -433,7 +434,7 @@ const appendWhereCondition = function(
const column = columnAliases[matches[2]] || matches[2];
const operator = opMapping[matches[3]];
const target = matches[4];
if (matches[3] == 'like') {
if (matches[3] == 'like' && clientType === 'pg') {
// handle uuid case
knexRef[`${key}`](
knexRef?.client.raw(`??::TEXT ${operator} '${target}'`, [

Loading…
Cancel
Save