From 07784069813979ecd7d898b9c0a21f041f332a0d Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 11 Feb 2022 12:29:36 +0800 Subject: [PATCH] fix: cast uuid in custom knex Signed-off-by: Wing-Kam Wong --- .../src/lib/dataMapper/lib/sql/CustomKnex.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts index ed9873ffc8..2bc54227dd 100644 --- a/packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts +++ b/packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts @@ -430,11 +430,19 @@ const appendWhereCondition = function( ); break; case '': - knexRef[`${key}`]( - columnAliases[matches[2]] || matches[2], - opMapping[matches[3]], - matches[4] - ); + const column = (columnAliases[matches[2]] || matches[2]); + const operator = opMapping[matches[3]]; + const target = matches[4]; + if (matches[3] == 'like') { + // handle uuid case + knexRef[`${key}`]( + knexRef?.client.raw(`??::TEXT ${operator} '${target}'`, [ + column + ]) + ); + } else { + knexRef[`${key}`](column, operator, target); + } break; default: throw new Error(`${matches[1] || ''} Invalid operation.`); @@ -991,6 +999,7 @@ export { Knex }; * * @author Naveen MR * @author Pranav C Balan + * @author Wing-Kam Wong * * @license GNU AGPL version 3 or any later version *