Skip to content

Commit

Permalink
fix: in operator handle empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
shan-mx committed Nov 24, 2024
1 parent cb2c42c commit 9970588
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 9970588

Please sign in to comment.