Skip to content

Commit

Permalink
fix(community): PrismaVectorStore handle empty array in filter (#7254)
Browse files Browse the repository at this point in the history
Co-authored-by: jacoblee93 <[email protected]>
  • Loading branch information
shan-mx and jacoblee93 authored Nov 25, 2024
1 parent 3460b92 commit 53d8ff5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libs/langchain-community/src/vectorstores/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)})`;
Expand Down

0 comments on commit 53d8ff5

Please sign in to comment.