diff --git a/package-shared/functions/dsql/sql/sql-generator.js b/package-shared/functions/dsql/sql/sql-generator.js index 2459145..c4df218 100644 --- a/package-shared/functions/dsql/sql/sql-generator.js +++ b/package-shared/functions/dsql/sql/sql-generator.js @@ -35,8 +35,12 @@ function sqlGenerator({ tableName, genObject }) { typeof queryObj.value == "number" ) { const valueParsed = String(queryObj.value); + if (queryObj.equality == "LIKE") { str = `LOWER(${finalFieldName}) LIKE LOWER('%${valueParsed}%')`; + } else if (queryObj.equality == "NOT EQUAL") { + str = `${finalFieldName} != ?`; + sqlSearhValues.push(valueParsed); } else { sqlSearhValues.push(valueParsed); } @@ -49,6 +53,9 @@ function sqlGenerator({ tableName, genObject }) { strArray.push( `LOWER(${finalFieldName}) LIKE LOWER('%${valueParsed}%')` ); + } else if (queryObj.equality == "NOT EQUAL") { + strArray.push(`${finalFieldName} != ?`); + sqlSearhValues.push(valueParsed); } else { strArray.push(`${finalFieldName} = ?`); sqlSearhValues.push(valueParsed); diff --git a/package-shared/types/index.d.ts b/package-shared/types/index.d.ts index ece093a..2125294 100644 --- a/package-shared/types/index.d.ts +++ b/package-shared/types/index.d.ts @@ -917,7 +917,7 @@ export type ServerQueryParam = { strategy: "ASC" | "DESC"; }; searchOperator?: "AND" | "OR"; - searchEquality?: "EQUAL" | "LIKE"; + searchEquality?: "EQUAL" | "LIKE" | "NOT EQUAL"; addUserId?: { fieldName: string; }; @@ -931,7 +931,7 @@ export type ServerQueryQueryObject = [key in keyof T]: { value: string | string[]; operator?: "AND" | "OR"; - equality?: "EQUAL" | "LIKE"; + equality?: "EQUAL" | "LIKE" | "NOT EQUAL"; tableName?: string; }; }; diff --git a/package.json b/package.json index f26f58c..ec2e895 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "3.1.9", + "version": "3.2.0", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {