Skip to content

Commit

Permalink
added supabase boolean column functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-w-nick committed Dec 20, 2024
1 parent eeaafd4 commit 21f1504
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libs/langchain-community/src/structured_query/supabase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
isFilterEmpty,
isBoolean,
isFloat,
isInt,
isObject,
Expand Down Expand Up @@ -28,8 +29,8 @@ import {
* structured query. It can be a string or a number.
*/
type ValueType = {
eq: string | number;
ne: string | number;
eq: string | number | boolean;
ne: string | number | boolean;
lt: string | number;
lte: string | number;
gt: string | number;
Expand Down Expand Up @@ -126,14 +127,16 @@ export class SupabaseTranslator<
* @param includeType Whether to include the data type in the column name.
* @returns The built column name.
*/
buildColumnName(attr: string, value: string | number, includeType = true) {
buildColumnName(attr: string, value: string | number | boolean, includeType = true) {
let column = "";
if (isString(value)) {
column = `metadata->>${attr}`;
} else if (isInt(value)) {
column = `metadata->${attr}${includeType ? "::int" : ""}`;
} else if (isFloat(value)) {
column = `metadata->${attr}${includeType ? "::float" : ""}`;
} else if(isBoolean(value)) {
column = `metadata->${attr}${includeType ? "::bool" : ""}`;
} else {
throw new Error("Data type not supported");
}
Expand Down

0 comments on commit 21f1504

Please sign in to comment.