multi-db-orm 2.1.23 → 2.1.25

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/engines/mysqldb.js +14 -5
  2. package/package.json +1 -1
@@ -157,12 +157,13 @@ class MySQLDB extends MultiDbORM {
157
157
  let val = object[key]
158
158
  if (typeof val == 'object')
159
159
  val = JSON.stringify(object[key])
160
+ val = this.pool.escape(val)
160
161
  if (typeof val == "undefined")
161
162
  vals = vals + `Null,`;
162
163
  else if (typeof val == 'boolean')
163
164
  vals = vals + `${val},`;
164
165
  else
165
- vals = vals + `'${val}',`;
166
+ vals = vals + `${val},`;
166
167
  }
167
168
  cols = cols.substring(0, cols.length - 1);
168
169
  vals = vals.substring(0, vals.length - 1);
@@ -192,20 +193,28 @@ class MySQLDB extends MultiDbORM {
192
193
  }
193
194
  for (var key in object) {
194
195
  let val = object[key]
196
+ if (typeof val == 'object' && val != undefined && val != null)
197
+ val = JSON.stringify(object[key])
198
+ val = this.pool.escape(val)
199
+
195
200
  if ( val == "undefined" || val == undefined || val == 'null'|| val == null)
196
201
  vals = vals + `${key} = Null,`;
197
- else if (typeof val == 'object')
198
- val = vals + `${key} = '${JSON.stringify(object[key])}',`
199
202
  else if (typeof val == 'boolean')
200
203
  vals = vals + `${key} = ${val},`;
201
204
  else
202
- vals = vals + `${key} = '${val}',`;
205
+ vals = vals + `${key} = ${val},`;
203
206
  }
204
207
  where = where + " 1 ";
205
208
  vals = vals.substring(0, vals.length - 1);
206
209
 
207
210
  var query = `UPDATE ${modelname} SET ${vals} WHERE ${where};`;
208
- return await this.run(query);
211
+ try{
212
+ return await this.run(query);
213
+ }catch(e){
214
+ if(this.loglevel > 4)
215
+ console.log('Error in update',e)
216
+ throw e;
217
+ }
209
218
  }
210
219
 
211
220
  async delete(modelname, filter) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multi-db-orm",
3
- "version": "2.1.23",
3
+ "version": "2.1.25",
4
4
  "description": "CRUD , Backup , Restore and Migration library for multiple databases",
5
5
  "main": "index.js",
6
6
  "dependencies": {