From 997058891eda130d4c17587b4600eb5099840cbe Mon Sep 17 00:00:00 2001 From: Alex Shan Date: Sun, 24 Nov 2024 15:11:03 +0800 Subject: [PATCH 1/2] fix: in operator handle empty array --- libs/langchain-community/src/vectorstores/prisma.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/langchain-community/src/vectorstores/prisma.ts b/libs/langchain-community/src/vectorstores/prisma.ts index 669fb51a5262..42e83c16ec03 100644 --- a/libs/langchain-community/src/vectorstores/prisma.ts +++ b/libs/langchain-community/src/vectorstores/prisma.ts @@ -437,6 +437,16 @@ export class PrismaVectorStore< )}` ); } + + if (value.length === 0) { + const isInOperator = OpMap[opNameKey] === OpMap.in; + + // For empty arrays: + // - IN () should return FALSE (nothing can be in an empty set) + // - NOT IN () should return TRUE (everything is not in an empty set) + return this.Prisma.sql`${!isInOperator}`; + } + return this.Prisma.sql`${colRaw} ${opRaw} (${this.Prisma.join( value )})`; From cc7514b639829242abec97b154ee398b4286bc49 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Mon, 25 Nov 2024 09:32:04 -0800 Subject: [PATCH 2/2] Format --- libs/langchain-community/src/vectorstores/prisma.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain-community/src/vectorstores/prisma.ts b/libs/langchain-community/src/vectorstores/prisma.ts index 42e83c16ec03..e61bb861eec2 100644 --- a/libs/langchain-community/src/vectorstores/prisma.ts +++ b/libs/langchain-community/src/vectorstores/prisma.ts @@ -446,7 +446,7 @@ export class PrismaVectorStore< // - NOT IN () should return TRUE (everything is not in an empty set) return this.Prisma.sql`${!isInOperator}`; } - + return this.Prisma.sql`${colRaw} ${opRaw} (${this.Prisma.join( value )})`;