@abaplint/runtime 2.13.82 → 2.13.83

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.
@@ -42,8 +42,11 @@ export interface DatabaseClient {
42
42
  disconnect(): Promise<void>;
43
43
  /*** execute any native SQL command */
44
44
  execute(sql: string | string[]): Promise<void>;
45
+ /*** no-op if a transaction is already open */
45
46
  beginTransaction(): Promise<void>;
47
+ /*** no-op if no transaction is open */
46
48
  commit(): Promise<void>;
49
+ /*** no-op if no transaction is open */
47
50
  rollback(): Promise<void>;
48
51
  delete(options: DeleteDatabaseOptions): Promise<{
49
52
  subrc: number;
@@ -21,6 +21,13 @@ function assign(input) {
21
21
  for (const s of split) {
22
22
  const upperS = s.toUpperCase().trimEnd();
23
23
  if (upperS === "*") {
24
+ if (!(input.dynamicSource instanceof types_1.DataReference)
25
+ && !(input.dynamicSource instanceof types_1.FieldSymbol)) {
26
+ // an earlier segment resolved to nothing, or to something that has
27
+ // no address, so the name cannot be followed: sy-subrc 4
28
+ abap.builtin.sy.get().subrc.set(4);
29
+ return;
30
+ }
24
31
  // @ts-ignore
25
32
  input.dynamicSource = input.dynamicSource.dereference();
26
33
  }
@@ -1 +1,8 @@
1
- export declare function commit(): void;
1
+ import { Context } from "../context";
2
+ export interface ICommitOptions {
3
+ /** COMMIT CONNECTION, name of the database connection to commit */
4
+ connection?: string;
5
+ /** COMMIT WORK AND WAIT, note that updates are always executed synchronously */
6
+ wait?: boolean;
7
+ }
8
+ export declare function commit(context: Context, options?: ICommitOptions): Promise<void>;
@@ -1,7 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.commit = commit;
4
- function commit() {
5
- // todo
4
+ async function commit(context, options) {
5
+ if (options?.connection !== undefined) {
6
+ const db = context.databaseConnections[options.connection];
7
+ if (db === undefined) {
8
+ throw new Error(`COMMIT CONNECTION, unknown connection "${options.connection}"`);
9
+ }
10
+ await db.commit();
11
+ return;
12
+ }
13
+ // COMMIT WORK ends the current LUW, ie. all open database connections are committed
14
+ for (const name of Object.keys(context.databaseConnections)) {
15
+ await context.databaseConnections[name].commit();
16
+ }
17
+ // sy-subrc is only set when the WAIT addition is specified
18
+ if (options?.wait === true) {
19
+ abap.builtin.sy.get().subrc.set(0);
20
+ }
6
21
  }
7
22
  //# sourceMappingURL=commit.js.map
@@ -1,7 +1,7 @@
1
1
  import { append } from "./append";
2
2
  import { assert } from "./assert";
3
3
  import { assign } from "./assign";
4
- import { commit } from "./commit";
4
+ import { ICommitOptions } from "./commit";
5
5
  import { concatenate } from "./concatenate";
6
6
  import { condense } from "./condense";
7
7
  import { convert } from "./convert";
@@ -33,7 +33,7 @@ import { modifyInternal } from "./modify_internal";
33
33
  import { moveCorresponding } from "./move_corresponding";
34
34
  import { readTable } from "./read_table";
35
35
  import { replace } from "./replace";
36
- import { rollback } from "./rollback";
36
+ import { IRollbackOptions } from "./rollback";
37
37
  import { setBit } from "./set_bit";
38
38
  import { shift } from "./shift";
39
39
  import { sort } from "./sort";
@@ -59,7 +59,6 @@ export declare class Statements {
59
59
  assign: typeof assign;
60
60
  cast: typeof cast;
61
61
  collect: typeof collect;
62
- commit: typeof commit;
63
62
  concatenate: typeof concatenate;
64
63
  condense: typeof condense;
65
64
  convert: typeof convert;
@@ -81,7 +80,6 @@ export declare class Statements {
81
80
  raiseEvent: typeof raiseEvent;
82
81
  readTable: typeof readTable;
83
82
  replace: typeof replace;
84
- rollback: typeof rollback;
85
83
  setBit: typeof setBit;
86
84
  setHandler: typeof setHandler;
87
85
  setLocale: typeof setLocale;
@@ -99,6 +97,8 @@ export declare class Statements {
99
97
  openCursor(target: INumeric, select: string, options: IOpenCursorDatabaseOptions): Promise<void>;
100
98
  fetchNextCursor(cursor: INumeric, target: any, packageSize?: INumeric): Promise<void>;
101
99
  closeCursor(cursor: INumeric): Promise<void>;
100
+ commit(options?: ICommitOptions): Promise<void>;
101
+ rollback(options?: IRollbackOptions): Promise<void>;
102
102
  deleteDatabase(table: string | ICharacter, options: IDeleteDatabaseOptions): Promise<void>;
103
103
  insertDatabase(table: string | ICharacter, options: IInsertDatabaseOptions): Promise<number | undefined>;
104
104
  modifyDatabase(table: string | ICharacter, options: IModifyDatabaseOptions): Promise<void>;
@@ -62,7 +62,6 @@ class Statements {
62
62
  assign = assign_1.assign;
63
63
  cast = cast_1.cast;
64
64
  collect = collect_1.collect;
65
- commit = commit_1.commit;
66
65
  concatenate = concatenate_1.concatenate;
67
66
  condense = condense_1.condense;
68
67
  convert = convert_1.convert;
@@ -84,7 +83,6 @@ class Statements {
84
83
  raiseEvent = raise_event_1.raiseEvent;
85
84
  readTable = read_table_1.readTable;
86
85
  replace = replace_1.replace;
87
- rollback = rollback_1.rollback;
88
86
  setBit = set_bit_1.setBit;
89
87
  setHandler = set_handler_1.setHandler;
90
88
  setLocale = set_locale_1.setLocale;
@@ -113,6 +111,12 @@ class Statements {
113
111
  async closeCursor(cursor) {
114
112
  await (0, close_cursor_1.closeCursor)(this.context, cursor.get());
115
113
  }
114
+ async commit(options) {
115
+ return (0, commit_1.commit)(this.context, options);
116
+ }
117
+ async rollback(options) {
118
+ return (0, rollback_1.rollback)(this.context, options);
119
+ }
116
120
  async deleteDatabase(table, options) {
117
121
  await (0, delete_database_1.deleteDatabase)(table, options, this.context);
118
122
  }
@@ -1 +1,6 @@
1
- export declare function rollback(): void;
1
+ import { Context } from "../context";
2
+ export interface IRollbackOptions {
3
+ /** ROLLBACK CONNECTION, name of the database connection to roll back */
4
+ connection?: string;
5
+ }
6
+ export declare function rollback(context: Context, options?: IRollbackOptions): Promise<void>;
@@ -1,7 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rollback = rollback;
4
- function rollback() {
5
- // todo
4
+ async function rollback(context, options) {
5
+ if (options?.connection !== undefined) {
6
+ const db = context.databaseConnections[options.connection];
7
+ if (db === undefined) {
8
+ throw new Error(`ROLLBACK CONNECTION, unknown connection "${options.connection}"`);
9
+ }
10
+ await db.rollback();
11
+ return;
12
+ }
13
+ // ROLLBACK WORK ends the current LUW, ie. all open database connections are rolled back
14
+ for (const name of Object.keys(context.databaseConnections)) {
15
+ await context.databaseConnections[name].rollback();
16
+ }
6
17
  }
7
18
  //# sourceMappingURL=rollback.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.13.82",
3
+ "version": "2.13.83",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",