@abaplint/runtime 2.7.4 → 2.7.6

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.
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expandIN = void 0;
4
4
  // note: must always return an expression, never return empty string
5
+ // https://www.sqlite.org/lang_select.html
5
6
  function expandIN(fieldName, table) {
6
7
  var _a, _b, _c;
7
8
  let ret = "";
8
9
  if (table.array().length === 0) {
9
- ret = fieldName + " NOT IN ()";
10
+ // " NOT IN ()" does not work on postgres
11
+ ret = fieldName + " LIKE '%'";
10
12
  }
11
13
  else {
12
14
  ret = fieldName + " IN (";
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeleteDatabase = void 0;
4
4
  const types_1 = require("../types");
5
+ const insert_database_1 = require("./insert_database");
5
6
  class DeleteDatabase {
6
7
  constructor(context) {
7
8
  this.context = context;
@@ -25,8 +26,7 @@ class DeleteDatabase {
25
26
  let where = [];
26
27
  const structure = options.from.get();
27
28
  for (const k of Object.keys(structure)) {
28
- // todo, integers should not be surrounded by '"'?
29
- const str = k + ' = "' + structure[k].get() + '"';
29
+ const str = k + " = " + (0, insert_database_1.toValue)(structure[k].get());
30
30
  where.push(str);
31
31
  }
32
32
  where = where.join(" AND ");
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InsertDatabase = exports.toValue = void 0;
4
4
  function toValue(value) {
5
5
  if (typeof value === "string") {
6
- return '"' + value.replace(/"/g, "\"\"") + '"';
6
+ // postgres requires ' for values
7
+ return "'" + value.replace(/'/g, "''") + "'";
8
+ // return '"' + value.replace(/"/g, "\"\"") + '"';
7
9
  }
8
10
  else {
9
11
  return value;
@@ -43,7 +45,7 @@ class InsertDatabase {
43
45
  values.push(toValue(value));
44
46
  }
45
47
  if (typeof table !== "string") {
46
- table = table.get().trimEnd();
48
+ table = table.get().trimEnd().toLowerCase();
47
49
  }
48
50
  const { subrc, dbcnt } = await this.context.defaultDB().insert({ table, columns, values });
49
51
  // @ts-ignore
@@ -34,7 +34,7 @@ class Structure {
34
34
  this.set(input.getPointer());
35
35
  }
36
36
  else if (input instanceof table_1.Table) {
37
- throw "Structure, input is a table";
37
+ throw new Error("Structure, input is a table");
38
38
  }
39
39
  else if (input instanceof Structure) {
40
40
  const obj = input.get();
@@ -129,13 +129,22 @@ class HashedTable {
129
129
  }
130
130
  buildHashFromSimple(data) {
131
131
  let hash = "";
132
+ const rowType = (0, clone_1.clone)(this.getRowType());
132
133
  for (const k of this.options.primaryKey.keyFields) {
133
134
  let val = data[k.toLowerCase()];
134
135
  if (val instanceof structure_1.Structure) {
135
136
  val = val.getCharacter();
136
137
  }
137
138
  else {
138
- val = val.get();
139
+ // convert to correct type, eg Chars have specific length, or rounding,
140
+ if (k === "TABLE_LINE") {
141
+ rowType.set(val.get());
142
+ val = rowType.get();
143
+ }
144
+ else {
145
+ rowType.get()[k.toLowerCase()].set(val.get());
146
+ val = rowType.get()[k.toLowerCase()].get();
147
+ }
139
148
  }
140
149
  hash += k + ":" + val + "|";
141
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.7.4",
3
+ "version": "2.7.6",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",