All files / output cl_sql_statement.clas.mjs

68.22% Statements 73/107
47.36% Branches 9/19
46.15% Functions 6/13
68.22% Lines 73/107

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 1071x 1x 2x 2x 2x 2x 2x 2x 2x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x     2x 2x 2x 2x           2x 10x 10x 10x 10x 10x 10x 10x 10x     10x         10x 10x 10x     10x         10x 2x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x     6x         6x 6x 6x 6x 6x                   6x 6x 2x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// cl_sql_statement.clas.abap
class cl_sql_statement {
  static STATIC_SUPER = undefined;
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CL_SQL_STATEMENT';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"MV_CONNECTION": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "}};
  static METHODS = {"CONSTRUCTOR": {"visibility": "U", "parameters": {"CON_REF": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_SQL_CONNECTION", RTTIName: "\\CLASS=CL_SQL_CONNECTION"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}}},
  "EXECUTE_UPDATE": {"visibility": "U", "parameters": {"STATEMENT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}},
  "EXECUTE_QUERY": {"visibility": "U", "parameters": {"RESULT_SET": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_SQL_RESULT_SET", RTTIName: "\\CLASS=CL_SQL_RESULT_SET"});}, "is_optional": " ", "parm_kind": "R", "type_name": "ObjectReferenceType"}, "STATEMENT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}},
  "EXECUTE_DDL": {"visibility": "U", "parameters": {"STATEMENT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}}};
  #mv_connection;
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "execute_update": this.execute_update.bind(this),
      "execute_query": this.execute_query.bind(this),
      "execute_ddl": this.execute_ddl.bind(this),
    };
    this.#mv_connection = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_connection"] = this.#mv_connection;
  }
  async constructor_(INPUT) {
    let con_ref = new abap.types.ABAPObject({qualifiedName: "CL_SQL_CONNECTION", RTTIName: "\\CLASS=CL_SQL_CONNECTION"});
    if (INPUT && INPUT.con_ref) {con_ref.set(INPUT.con_ref);}
    if (abap.compare.initial(con_ref)) {
      this.#mv_connection.set(abap.CharacterFactory.get(7, 'DEFAULT'));
    } else {
      this.#mv_connection.set((await con_ref.get().get_con_name()));
    }
    abap.statements.assert(abap.compare.initial(this.#mv_connection) === false);
    return this;
  }
  async execute_ddl(INPUT) {
    let statement = INPUT?.statement;
    if (statement?.getQualifiedName === undefined || statement.getQualifiedName() !== "STRING") { statement = undefined; }
    if (statement === undefined) { statement = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.statement); }
    abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(13, 'not supported')));
  }
  async execute_update(INPUT) {
    let statement = INPUT?.statement;
    if (statement?.getQualifiedName === undefined || statement.getQualifiedName() !== "STRING") { statement = undefined; }
    if (statement === undefined) { statement = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.statement); }
    let lv_sql_message = new abap.types.String({qualifiedName: "STRING"});
    let connection = new abap.types.String({qualifiedName: "STRING"});
    abap.statements.assert(abap.compare.initial(statement) === false);
    connection.set(this.#mv_connection);
    if (abap.context.databaseConnections[connection.get()] === undefined) {
      lv_sql_message.set(abap.CharacterFactory.get(19, 'not connected to db'));
    }
    if (abap.compare.initial(lv_sql_message) === false) {
      const unique1380 = await (new abap.Classes['CX_SQL_EXCEPTION']()).constructor_();
      unique1380.EXTRA_CX = {"INTERNAL_FILENAME": "cl_sql_statement.clas.abap","INTERNAL_LINE": 59};
      throw unique1380;
    }
    try {
        await abap.context.databaseConnections[connection.get()].execute(statement.get());
    } catch(e) {
        lv_sql_message.set(e + "");
    }
    if (abap.compare.initial(lv_sql_message) === false) {
      const unique1381 = await (new abap.Classes['CX_SQL_EXCEPTION']()).constructor_();
      unique1381.EXTRA_CX = {"INTERNAL_FILENAME": "cl_sql_statement.clas.abap","INTERNAL_LINE": 68};
      throw unique1381;
    }
  }
  async execute_query(INPUT) {
    let result_set = new abap.types.ABAPObject({qualifiedName: "CL_SQL_RESULT_SET", RTTIName: "\\CLASS=CL_SQL_RESULT_SET"});
    let statement = INPUT?.statement;
    if (statement?.getQualifiedName === undefined || statement.getQualifiedName() !== "STRING") { statement = undefined; }
    if (statement === undefined) { statement = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.statement); }
    let lx_osql = new abap.types.ABAPObject({qualifiedName: "CX_SY_DYNAMIC_OSQL_SEMANTICS", RTTIName: "\\CLASS=CX_SY_DYNAMIC_OSQL_SEMANTICS"});
    let lv_sql_message = new abap.types.String({qualifiedName: "STRING"});
    let connection = new abap.types.String({qualifiedName: "STRING"});
    connection.set(this.#mv_connection);
    abap.statements.assert(abap.compare.initial(statement) === false);
    abap.statements.assert(abap.compare.initial(this.#mv_connection) === false);
    if (abap.context.databaseConnections[connection.get()] === undefined) {
      lv_sql_message.set(abap.CharacterFactory.get(19, 'not connected to db'));
    }
    if (abap.compare.initial(lv_sql_message) === false) {
      const unique1382 = await (new abap.Classes['CX_SQL_EXCEPTION']()).constructor_({sql_message: lv_sql_message});
      unique1382.EXTRA_CX = {"INTERNAL_FILENAME": "cl_sql_statement.clas.abap","INTERNAL_LINE": 88};
      throw unique1382;
    }
    result_set.set(await (new abap.Classes['CL_SQL_RESULT_SET']()).constructor_());
    try {
        const res = await abap.context.databaseConnections[connection.get()].select({select: statement.get()});
        result_set.get().mv_magic = res.rows;
    } catch (e) {
      if ((abap.Classes['CX_SY_DYNAMIC_OSQL_SEMANTICS'] && e instanceof abap.Classes['CX_SY_DYNAMIC_OSQL_SEMANTICS'])) {
        lx_osql.set(e);
        const unique1383 = await (new abap.Classes['CX_SQL_EXCEPTION']()).constructor_({sql_message: lx_osql.get().sqlmsg});
        unique1383.EXTRA_CX = {"INTERNAL_FILENAME": "cl_sql_statement.clas.abap","INTERNAL_LINE": 98};
        throw unique1383;
      } else {
        throw e;
      }
    }
    return result_set;
  }
}
abap.Classes['CL_SQL_STATEMENT'] = cl_sql_statement;
export {cl_sql_statement};