Closed standuprey closed 4 months ago
It seems the notIn
operator is indeed missing from the PrismaSqlFilter
type definition in LangChain.js, which aligns with the error you're encountering. This omission means that directly using notIn
within PrismaSqlFilter
isn't supported in the current implementation.
For a workaround, consider using the addNotClause
method as an alternative approach to achieve a similar effect. This method allows for negating conditions, which could potentially mimic the notIn
behavior by creatively using negation with other operations. Here's how you might use it:
addNotClause(column: string, operator: string, value: unknown) {
this.values.push([column, `not.${operator}.${value}`]);
}
This snippet demonstrates applying a not
operation, which can simulate notIn
by negating an in
condition or similar. Keep in mind, this is a workaround and might not cover all use cases as directly as notIn
would.
To continue the conversation, mention @dosu.
@dosu I am not seeing any addNotClause
in the documentation or source code, can point it out to me? which package?
It appears there was a misunderstanding regarding the addNotClause
method, as it's not directly related to Prisma or the PrismaSqlFilter
type definition but rather to handling queries within LangChain.js, specifically for Supabase utilities. The method I mentioned doesn't exist in the context you're working with and was an error in my explanation.
For implementing a notIn
functionality with Prisma in LangChain.js, since the notIn
operator is missing from the PrismaSqlFilter
, you would typically look for alternative approaches within Prisma's querying capabilities. However, since the context has shifted towards Supabase and not Prisma, my previous advice was misplaced.
If you're working with Supabase in LangChain.js and need to apply a notIn
logic, you would directly use Supabase's querying functions, which allow for a wide range of conditional operations, including negations and exclusions, without needing a workaround like an addNotClause
method.
For Prisma, if you need to implement a notIn
condition and it's not supported in your current version or setup, you might consider updating your Prisma version or checking Prisma's documentation for the latest on how to handle such cases, as Prisma regularly updates its query capabilities and type definitions.
I apologize for the confusion and hope this clarifies the situation.
To continue the conversation, mention @dosu.
It seems that the logic for the notIn operator has not been implemented yet, but it appears to be highly similar to the in operator. If this approach works, I can submit a pull request. @standuprey
Implementing the notIn
logic in the PrismaSqlFilter
type definition for LangChain.js, similarly to the in
operator, is indeed a viable solution for the missing notIn
operator issue. You can proceed with submitting a pull request. Here's a concise guide on how to add notIn
functionality:
Extend PrismaSqlFilter
Type: Add notIn
to the type definition to include arrays of the model's type.
notIn?: TModel[K][];
Update the OpMap
: Include notIn
in the operation mapping with the SQL NOT IN
operation.
notIn: "NOT IN",
Implement notIn
Logic: Modify the buildSqlFilterStr
method to handle notIn
by constructing the appropriate SQL query part.
case OpMap.notIn: {
// Ensure value is an array and construct the SQL part
}
Remember to update or extend the existing tests to cover the new notIn
operator, ensuring it behaves as expected within the framework.
When implementing notIn
, consider the potential performance implications, especially with large exclusion lists, as it might affect query efficiency depending on the database's indexing and configuration.
Ensure your contribution adheres to the LangChain JS repository's coding standards and guidelines, including following the "fork and pull request" workflow, adhering to linting rules, including tests, and documenting your changes. Check the CONTRIBUTING.md
document and the integration contribution guide for more details on contributing to LangChain JS.
To continue the conversation, mention @dosu.
Yes, that'd be a great improvement as far as I'm concerned
Checked other resources
Example Code
The following code:
Error Message and Stack Trace (if applicable)
No response
Description
An error is saying
'notIn' does not exist in type '{ equals?: number; in?: number[]; isNull?: number; isNotNull?: number; like?: number; lt?: number; lte?: number; gt?: number; gte?: number; not?: number; }'
unsurprisingly, the
notIn
Prisma operator missing inPrismaSqlFilter
:This issue was already mentioned here: https://github.com/langchain-ai/langchainjs/issues/692#issuecomment-1627462362
System Info