@autofleet/sadot 0.5.5-beta.4 → 0.5.5-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,18 +4,18 @@ exports.buildCustomFieldsSearchWhereClause = void 0;
4
4
  /* eslint-disable import/prefer-default-export */
5
5
  const sequelize_1 = require("sequelize");
6
6
  const sequelize_typescript_1 = require("sequelize-typescript");
7
- const buildCustomFieldsSearchWhereClause = (modelName) => ({
8
- [sequelize_1.Op.or]: [
9
- sequelize_typescript_1.Sequelize.where(sequelize_typescript_1.Sequelize.literal(`
10
- EXISTS (
11
- SELECT 1
12
- FROM "custom_field_values" AS "cv"
13
- WHERE
14
- "cv"."deleted_at" IS NULL
15
- AND "cv"."model_id" = "${modelName}"."id"
16
- AND CAST("cv"."value" AS TEXT) ILIKE :searchTerm
17
- )
18
- `), true),
19
- ],
20
- });
7
+ const buildCustomFieldsSearchWhereClause = (modelName) => {
8
+ const subQuery = `${'EXISTS ('
9
+ + ' SELECT 1'
10
+ + ' FROM "custom_field_values" AS "cv"'
11
+ + ' WHERE'
12
+ + ' "cv"."deleted_at" IS NULL'
13
+ + ` AND "cv"."model_id" = "${modelName}"."id"`
14
+ + ' AND CAST("cv"."value" AS TEXT) ILIKE :searchTerm)'}`;
15
+ return {
16
+ [sequelize_1.Op.or]: [
17
+ sequelize_typescript_1.Sequelize.where(sequelize_typescript_1.Sequelize.literal(subQuery), true),
18
+ ],
19
+ };
20
+ };
21
21
  exports.buildCustomFieldsSearchWhereClause = buildCustomFieldsSearchWhereClause;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sadot",
3
- "version": "0.5.5-beta.4",
3
+ "version": "0.5.5-beta.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -2,17 +2,19 @@
2
2
  import { WhereOptions, Op } from 'sequelize';
3
3
  import { Sequelize } from 'sequelize-typescript';
4
4
 
5
- export const buildCustomFieldsSearchWhereClause = (modelName: string): WhereOptions => ({
6
- [Op.or]: [
7
- Sequelize.where(Sequelize.literal(`
8
- EXISTS (
9
- SELECT 1
10
- FROM "custom_field_values" AS "cv"
11
- WHERE
12
- "cv"."deleted_at" IS NULL
13
- AND "cv"."model_id" = "${modelName}"."id"
14
- AND CAST("cv"."value" AS TEXT) ILIKE :searchTerm
15
- )
16
- `), true),
17
- ],
18
- });
5
+ export const buildCustomFieldsSearchWhereClause = (modelName: string): WhereOptions => {
6
+ const subQuery = `${
7
+ 'EXISTS ('
8
+ + ' SELECT 1'
9
+ + ' FROM "custom_field_values" AS "cv"'
10
+ + ' WHERE'
11
+ + ' "cv"."deleted_at" IS NULL'
12
+ + ` AND "cv"."model_id" = "${modelName}"."id"`
13
+ + ' AND CAST("cv"."value" AS TEXT) ILIKE :searchTerm)'
14
+ }`;
15
+ return {
16
+ [Op.or]: [
17
+ Sequelize.where(Sequelize.literal(subQuery), true),
18
+ ],
19
+ };
20
+ };