@abaplint/runtime 2.1.11 → 2.1.15

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.
@@ -18,6 +18,9 @@ export interface SelectDatabaseOptions {
18
18
  /** list of primary key fields, in lower case, if known */
19
19
  primaryKey?: string[];
20
20
  }
21
+ export interface SelectRuntimeOptions {
22
+ appending?: boolean;
23
+ }
21
24
  export declare type DatabaseValue = number | string | Uint8Array | null;
22
25
  export declare type DatabaseRow = {
23
26
  [name: string]: DatabaseValue;
@@ -39,7 +39,7 @@ import { ICharacter } from "../types/_character";
39
39
  import { FieldSymbol, Structure, Table } from "../types";
40
40
  import { INumeric } from "../types/_numeric";
41
41
  import { ICallFunctionOptions } from "./call_function";
42
- import { SelectDatabaseOptions } from "../db/db";
42
+ import { SelectDatabaseOptions, SelectRuntimeOptions } from "../db/db";
43
43
  export declare class Statements {
44
44
  append: typeof append;
45
45
  assert: typeof assert;
@@ -77,7 +77,7 @@ export declare class Statements {
77
77
  insertDatabase(table: string | ICharacter, options: IInsertDatabaseOptions): Promise<number>;
78
78
  message(options: IMessageOptions): Promise<void>;
79
79
  modifyDatabase(table: string | ICharacter, options: IModifyDatabaseOptions): Promise<void>;
80
- select(target: Structure | Table | FieldSymbol, select: SelectDatabaseOptions): Promise<void>;
80
+ select(target: Structure | Table | FieldSymbol, select: SelectDatabaseOptions, runtimeOptions?: SelectRuntimeOptions): Promise<void>;
81
81
  updateDatabase(table: string | ICharacter, options: IUpdateDatabaseOptions): Promise<number>;
82
82
  callFunction(options: ICallFunctionOptions): Promise<void>;
83
83
  write(source: INumeric | ICharacter | FieldSymbol | string | number, options?: IWriteOptions): void;
@@ -87,8 +87,8 @@ class Statements {
87
87
  async modifyDatabase(table, options) {
88
88
  return new modify_database_1.ModifyDatabase(this.context).modifyDatabase(table, options);
89
89
  }
90
- async select(target, select) {
91
- return new select_1.SelectDatabase(this.context).select(target, select);
90
+ async select(target, select, runtimeOptions) {
91
+ return new select_1.SelectDatabase(this.context).select(target, select, runtimeOptions);
92
92
  }
93
93
  async updateDatabase(table, options) {
94
94
  return new update_database_1.UpdateDatabase(this.context).updateDatabase(table, options);
@@ -1,8 +1,8 @@
1
1
  import { Context } from "../context";
2
- import { SelectDatabaseOptions } from "../db/db";
2
+ import { SelectDatabaseOptions, SelectRuntimeOptions } from "../db/db";
3
3
  import { FieldSymbol, Structure, Table } from "../types";
4
4
  export declare class SelectDatabase {
5
5
  private readonly context;
6
6
  constructor(context: Context);
7
- select(target: Structure | Table | FieldSymbol, input: SelectDatabaseOptions): Promise<void>;
7
+ select(target: Structure | Table | FieldSymbol, input: SelectDatabaseOptions, runtimeOptions?: SelectRuntimeOptions): Promise<void>;
8
8
  }
@@ -7,7 +7,7 @@ class SelectDatabase {
7
7
  constructor(context) {
8
8
  this.context = context;
9
9
  }
10
- async select(target, input) {
10
+ async select(target, input, runtimeOptions) {
11
11
  var _a;
12
12
  const { rows: rows } = await this.context.defaultDB().select(input);
13
13
  if (target instanceof types_1.FieldSymbol) {
@@ -17,7 +17,9 @@ class SelectDatabase {
17
17
  // @ts-ignore
18
18
  target = target.getPointer();
19
19
  }
20
- target.clear();
20
+ if ((runtimeOptions === null || runtimeOptions === void 0 ? void 0 : runtimeOptions.appending) !== true) {
21
+ target === null || target === void 0 ? void 0 : target.clear();
22
+ }
21
23
  if (rows.length === 0) {
22
24
  // @ts-ignore
23
25
  abap.builtin.sy.get().subrc.set(4);
@@ -42,11 +44,17 @@ class SelectDatabase {
42
44
  // @ts-ignore
43
45
  abap.statements.insertInternal({ table: target, data: targetRow });
44
46
  }
47
+ }
48
+ else if (target !== undefined) {
49
+ throw new Error("Runtime, SELECT todo");
50
+ }
51
+ if (target === undefined && rows.length === 1) {
45
52
  // @ts-ignore
46
- abap.builtin.sy.get().dbcnt.set(rows.length);
53
+ abap.builtin.sy.get().dbcnt.set(Object.values(rows[0])[0]);
47
54
  }
48
55
  else {
49
- throw new Error("Runtime, SELECT todo");
56
+ // @ts-ignore
57
+ abap.builtin.sy.get().dbcnt.set(rows.length);
50
58
  }
51
59
  // @ts-ignore
52
60
  abap.builtin.sy.get().subrc.set(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.1.11",
3
+ "version": "2.1.15",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",