zet-lib 1.2.26 → 1.2.27

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.
Files changed (2) hide show
  1. package/lib/connection.js +16 -2
  2. package/package.json +1 -1
package/lib/connection.js CHANGED
@@ -73,6 +73,8 @@ const whereFn = (obj) => {
73
73
  arr.push(where[key])
74
74
  increment++
75
75
  }
76
+ //console.log(whereArray);
77
+ let hasWhere = false
76
78
  wherequery = arr.length ? wherequery.join(' AND ') : ''
77
79
  if (whereArray.length) {
78
80
  let andOr = wherequery ? ' AND ' : ''
@@ -95,9 +97,11 @@ const whereFn = (obj) => {
95
97
  //JSON_CONTAINS(color, '"Red"' ,'$')
96
98
  if (item.isJSON) {
97
99
  wherequery += andOr + ` JSON_CONTAINS(${field}, '"${item.value}"' ,'$') ${operator}`
100
+ hasWhere = true
98
101
  } else {
99
102
  if (type == 'json') {
100
103
  wherequery += andOr + ` JSON_CONTAINS(${field}, '"${item.value}"' ,'$') ${operator}`
104
+ hasWhere = true
101
105
  } else if (type == 'inline') {
102
106
  //select * from attendance where employee_id = 4803 and date IN ('2023-12-21','2023-12-22')
103
107
  if (field) {
@@ -105,6 +109,7 @@ const whereFn = (obj) => {
105
109
  } else {
106
110
  wherequery += andOr + ` ${item.value} ${operator}`
107
111
  }
112
+ hasWhere = true
108
113
  } else {
109
114
  if (item.option.includes('{{value}}')) {
110
115
  item.option = item.option.replace('{{value}}', `$${increment}`)
@@ -127,12 +132,21 @@ const whereFn = (obj) => {
127
132
  })
128
133
  //console.log(arr)
129
134
  }
130
- const wheres = arr.length ? `WHERE ${wherequery}` : ''
131
- return {
135
+ if (arr.length > 0) {
136
+ hasWhere = true
137
+ }
138
+ let wheres = ''
139
+ if (hasWhere) {
140
+ wheres = `WHERE ${wherequery}`
141
+ }
142
+
143
+ let objAll = {
132
144
  where: wheres,
133
145
  arr: arr,
134
146
  increment: increment,
135
147
  }
148
+ //console.log(obj)
149
+ return objAll
136
150
  }
137
151
 
138
152
  connection.results = async (obj) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.2.26",
3
+ "version": "1.2.27",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"