multi-db-orm 3.0.2 → 3.0.4
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.
- package/README.md +1 -0
- package/engines/hanadb.js +11 -11
- package/package.json +1 -1
package/README.md
CHANGED
package/engines/hanadb.js
CHANGED
|
@@ -63,22 +63,22 @@ class HanaDB extends MultiDbORM {
|
|
|
63
63
|
this.metrics.get(modelname, filter, options);
|
|
64
64
|
let where = "";
|
|
65
65
|
for (const key in filter) {
|
|
66
|
-
where +=
|
|
66
|
+
where += `"${key}" = '${filter[key]}' AND `;
|
|
67
67
|
}
|
|
68
68
|
where += "1 = 1";
|
|
69
69
|
let sort = "";
|
|
70
70
|
if (options) {
|
|
71
71
|
if (options.apply) {
|
|
72
72
|
if (options.apply.ineq) {
|
|
73
|
-
where += ` AND ${options.apply.field} ${options.apply.ineq.op} '${options.apply.ineq.value}'`;
|
|
73
|
+
where += ` AND "${options.apply.field}" ${options.apply.ineq.op} '${options.apply.ineq.value}'`;
|
|
74
74
|
}
|
|
75
75
|
if (options.apply.sort) {
|
|
76
|
-
sort = `ORDER BY ${options.apply.field} ${options.apply.sort}`;
|
|
76
|
+
sort = `ORDER BY "${options.apply.field}" ${options.apply.sort}`;
|
|
77
77
|
}
|
|
78
78
|
} else if (options.sort) {
|
|
79
79
|
sort = "ORDER BY";
|
|
80
80
|
for (let i = 0; i < options.sort.length; i++) {
|
|
81
|
-
sort += ` ${options.sort[i].field} ${options.sort[i].order}`;
|
|
81
|
+
sort += ` "${options.sort[i].field}" ${options.sort[i].order}`;
|
|
82
82
|
if (i < options.sort.length - 1) {
|
|
83
83
|
sort += ", ";
|
|
84
84
|
}
|
|
@@ -102,7 +102,7 @@ class HanaDB extends MultiDbORM {
|
|
|
102
102
|
this.metrics.getOne(modelname, filter);
|
|
103
103
|
let where = "";
|
|
104
104
|
for (const key in filter) {
|
|
105
|
-
where +=
|
|
105
|
+
where += `"${key}" = '${filter[key]}' AND `;
|
|
106
106
|
}
|
|
107
107
|
where += "1 = 1";
|
|
108
108
|
const query = `SELECT * FROM ${modelname} WHERE ${where} LIMIT 1;`;
|
|
@@ -132,9 +132,9 @@ class HanaDB extends MultiDbORM {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
if (key.toLowerCase().trim() === "id") {
|
|
135
|
-
cols +=
|
|
135
|
+
cols += `"${key}" ${type} PRIMARY KEY NOT NULL ,`;
|
|
136
136
|
} else {
|
|
137
|
-
cols +=
|
|
137
|
+
cols += `"${key}" ${type},`;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
cols = cols.substring(0, cols.length - 1);
|
|
@@ -153,7 +153,7 @@ class HanaDB extends MultiDbORM {
|
|
|
153
153
|
let cols = "";
|
|
154
154
|
let vals = "";
|
|
155
155
|
for (const key in object) {
|
|
156
|
-
cols = cols +
|
|
156
|
+
cols = cols + `"${key}",`;
|
|
157
157
|
let val = object[key];
|
|
158
158
|
if (typeof val == "object") val = JSON.stringify(object[key]);
|
|
159
159
|
val = this.escapeSQLValue(val);
|
|
@@ -187,7 +187,7 @@ class HanaDB extends MultiDbORM {
|
|
|
187
187
|
let where = "";
|
|
188
188
|
let vals = "";
|
|
189
189
|
for (const key in filter) {
|
|
190
|
-
where +=
|
|
190
|
+
where += `"${key}" = '${filter[key]}' AND `;
|
|
191
191
|
}
|
|
192
192
|
for (const key in object) {
|
|
193
193
|
let val = object[key];
|
|
@@ -195,7 +195,7 @@ class HanaDB extends MultiDbORM {
|
|
|
195
195
|
val = JSON.stringify(object[key]);
|
|
196
196
|
val = this.escapeSQLValue(val);
|
|
197
197
|
|
|
198
|
-
vals +=
|
|
198
|
+
vals += `"${key}" = ${val},`;
|
|
199
199
|
}
|
|
200
200
|
where += "1 = 1";
|
|
201
201
|
vals = vals.slice(0, -1);
|
|
@@ -215,7 +215,7 @@ class HanaDB extends MultiDbORM {
|
|
|
215
215
|
|
|
216
216
|
let where = "";
|
|
217
217
|
for (const key in filter) {
|
|
218
|
-
where +=
|
|
218
|
+
where += `"${key}" = '${filter[key]}' AND `;
|
|
219
219
|
}
|
|
220
220
|
where += "1 = 1";
|
|
221
221
|
const query = `DELETE FROM ${modelname} WHERE ${where};`;
|