Skip to content

Commit 1a50e83

Browse files
authored
more ADBC (#921)
1 parent 51bc5dd commit 1a50e83

22 files changed

+261
-63
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
integration:
2020
needs: unit
2121
runs-on: ubuntu-latest
22-
timeout-minutes: 5
22+
timeout-minutes: 10
2323
env:
2424
HTTP_BIN_HOST: http://localhost:8080
2525
steps:
2626
- uses: actions/checkout@v4
2727
- uses: actions/setup-node@v4
28-
- run: docker run -d -p8080:80 kennethreitz/httpbin
28+
- run: npm run docker:start
2929
- run: npm install
3030
- run: npm run integration
3131
performance:

abaplint.jsonc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"inline_data_old_versions": false,
119119
"intf_referencing_clas": false,
120120
"keep_single_parameter_on_one_line": true,
121-
"line_break_multiple_parameters": false,
121+
"line_break_multiple_parameters": true,
122122
"line_break_style": false,
123123
"msag_consistency": true,
124124
"nesting": true,
@@ -182,7 +182,16 @@
182182
"check_ddic": true,
183183
"implement_methods": true,
184184
"indentation": true,
185-
"keyword_case": true,
185+
"keyword_case": {
186+
"style": "upper",
187+
"ignoreExceptions": false,
188+
"ignoreLowerClassImplmentationStatement": false,
189+
"ignoreGlobalClassDefinition": false,
190+
"ignoreGlobalInterface": false,
191+
"ignoreFunctionModuleName": false,
192+
"ignoreGlobalClassBoundaries": false,
193+
"ignoreKeywords": []
194+
},
186195
"when_others_last": true,
187196
"newline_between_methods": true,
188197
"avoid_use": {

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
"flame": "0x -o -- node --expose-gc test/performance.mjs",
1010
"performance": "rm -rf output && abap_transpile ./abap_transpile_test.json && node --expose-gc test/performance.mjs",
1111
"integration": "rm -rf output && abap_transpile ./abap_transpile_test.json && node --expose-gc output/index.mjs",
12+
"postgres:init": "cat test/adbc/init.sql | docker exec -i postgresql psql -U postgres -d postgres",
13+
"docker:start": "docker compose -p open-abap -f test/stack.yml up -d --wait && npm run postgres:init",
1214
"test": "npm run lint && npm run unit"
1315
},
1416
"license": "MIT",
1517
"dependencies": {
16-
"@abaplint/cli": "^2.113.91",
17-
"@abaplint/database-sqlite": "^2.10.20",
18-
"@abaplint/runtime": "^2.10.23",
19-
"@abaplint/transpiler-cli": "^2.10.23",
18+
"@abaplint/cli": "^2.113.99",
19+
"@abaplint/database-pg": "^2.10.24",
20+
"@abaplint/database-sqlite": "^2.10.24",
21+
"@abaplint/runtime": "^2.10.24",
22+
"@abaplint/transpiler-cli": "^2.10.24",
2023
"0x": "^5.8.0"
2124
}
2225
}

src/abap/math/cl_abap_random.clas.testclasses.abap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ CLASS ltcl_test IMPLEMENTATION.
2121
DATA lv_int TYPE i.
2222
lo_random = cl_abap_random=>create( ).
2323
DO 10 TIMES.
24-
lv_int = lo_random->intinrange( low = 10 high = 20 ).
24+
lv_int = lo_random->intinrange(
25+
low = 10
26+
high = 20 ).
2527
cl_abap_unit_assert=>assert_number_between(
2628
lower = 10
2729
upper = 20
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
CLASS cl_sql_connection DEFINITION PUBLIC.
2+
PUBLIC SECTION.
3+
CLASS-METHODS get_connection
4+
IMPORTING
5+
con_name TYPE clike
6+
sharable TYPE abap_bool DEFAULT abap_false
7+
RETURNING
8+
VALUE(connection) TYPE REF TO cl_sql_connection.
9+
10+
" added in 7.53
11+
CLASS-METHODS get_abap_connection
12+
IMPORTING
13+
con_name TYPE clike
14+
RETURNING
15+
VALUE(connection) TYPE REF TO cl_sql_connection.
16+
17+
METHODS create_statement
18+
RETURNING
19+
VALUE(statement) TYPE REF TO cl_sql_statement.
20+
21+
METHODS get_con_name
22+
RETURNING
23+
VALUE(con_name) TYPE string.
24+
25+
PRIVATE SECTION.
26+
DATA mv_con_name TYPE string.
27+
ENDCLASS.
28+
29+
CLASS cl_sql_connection IMPLEMENTATION.
30+
METHOD get_con_name.
31+
con_name = mv_con_name.
32+
ENDMETHOD.
33+
34+
METHOD create_statement.
35+
CREATE OBJECT statement EXPORTING con_ref = me.
36+
ENDMETHOD.
37+
38+
METHOD get_connection.
39+
" only supported for now,
40+
ASSERT sharable = abap_true.
41+
CREATE OBJECT connection.
42+
connection->mv_con_name = con_name.
43+
ENDMETHOD.
44+
45+
METHOD get_abap_connection.
46+
connection = get_connection(
47+
con_name = con_name
48+
sharable = abap_true ).
49+
ENDMETHOD.
50+
51+
ENDCLASS.

src/adbc/cl_sql_statement.clas.abap

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
CLASS cl_sql_statement DEFINITION PUBLIC.
22
PUBLIC SECTION.
33
METHODS constructor
4-
IMPORTING con_ref TYPE REF TO object OPTIONAL.
4+
IMPORTING
5+
con_ref TYPE REF TO cl_sql_connection OPTIONAL.
56

67
METHODS execute_update
78
IMPORTING
@@ -22,13 +23,21 @@ CLASS cl_sql_statement DEFINITION PUBLIC.
2223
statement TYPE string
2324
RAISING
2425
cx_sql_exception.
26+
27+
PRIVATE SECTION.
28+
DATA mv_connection TYPE string.
2529
ENDCLASS.
2630

2731
CLASS cl_sql_statement IMPLEMENTATION.
2832

2933
METHOD constructor.
30-
* todo,
31-
ASSERT con_ref IS INITIAL.
34+
IF con_ref IS INITIAL.
35+
mv_connection = 'DEFAULT'.
36+
ELSE.
37+
mv_connection = con_ref->get_con_name( ).
38+
ENDIF.
39+
40+
ASSERT mv_connection IS NOT INITIAL.
3241
ENDMETHOD.
3342

3443
METHOD execute_ddl.
@@ -41,15 +50,15 @@ CLASS cl_sql_statement IMPLEMENTATION.
4150

4251
ASSERT statement IS NOT INITIAL.
4352

44-
WRITE '@KERNEL if (abap.context.databaseConnections["DEFAULT"] === undefined) {'.
53+
WRITE '@KERNEL if (abap.context.databaseConnections[this.mv_connection.get()] === undefined) {'.
4554
lv_sql_message = 'not connected to db'.
4655
WRITE '@KERNEL }'.
4756
IF lv_sql_message IS NOT INITIAL.
4857
RAISE EXCEPTION TYPE cx_sql_exception.
4958
ENDIF.
5059

5160
WRITE '@KERNEL try {'.
52-
WRITE '@KERNEL await abap.context.databaseConnections["DEFAULT"].execute(statement.get());'.
61+
WRITE '@KERNEL await abap.context.databaseConnections[this.mv_connection.get()].execute(statement.get());'.
5362
WRITE '@KERNEL } catch(e) {'.
5463
WRITE '@KERNEL lv_sql_message.set(e + "");'.
5564
WRITE '@KERNEL }'.
@@ -60,29 +69,28 @@ CLASS cl_sql_statement IMPLEMENTATION.
6069
ENDMETHOD.
6170

6271
METHOD execute_query.
72+
DATA lx_osql TYPE REF TO cx_sy_dynamic_osql_semantics.
6373
DATA lv_sql_message TYPE string.
6474

6575
ASSERT statement IS NOT INITIAL.
76+
ASSERT mv_connection IS NOT INITIAL.
6677

67-
WRITE '@KERNEL if (abap.context.databaseConnections["DEFAULT"] === undefined) {'.
78+
WRITE '@KERNEL if (abap.context.databaseConnections[this.mv_connection.get()] === undefined) {'.
6879
lv_sql_message = 'not connected to db'.
6980
WRITE '@KERNEL }'.
7081
IF lv_sql_message IS NOT INITIAL.
71-
RAISE EXCEPTION TYPE cx_sql_exception.
82+
RAISE EXCEPTION TYPE cx_sql_exception EXPORTING sql_message = lv_sql_message.
7283
ENDIF.
7384

7485
CREATE OBJECT result_set.
7586

76-
WRITE '@KERNEL try {'.
77-
WRITE '@KERNEL const res = await abap.context.databaseConnections["DEFAULT"].select({select: statement.get()});'.
87+
TRY.
88+
WRITE '@KERNEL const res = await abap.context.databaseConnections[this.mv_connection.get()].select({select: statement.get()});'.
7889
* WRITE '@KERNEL console.dir(res.rows);'.
79-
WRITE '@KERNEL result_set.get().mv_magic = res.rows;'.
80-
WRITE '@KERNEL } catch(e) {'.
81-
WRITE '@KERNEL lv_sql_message.set(e + "");'.
82-
WRITE '@KERNEL }'.
83-
IF lv_sql_message IS NOT INITIAL.
84-
RAISE EXCEPTION TYPE cx_sql_exception.
85-
ENDIF.
90+
WRITE '@KERNEL result_set.get().mv_magic = res.rows;'.
91+
CATCH cx_sy_dynamic_osql_semantics INTO lx_osql.
92+
RAISE EXCEPTION TYPE cx_sql_exception EXPORTING sql_message = lx_osql->sqlmsg.
93+
ENDTRY.
8694

8795
ENDMETHOD.
8896

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
CLASS cx_sql_exception DEFINITION PUBLIC INHERITING FROM cx_static_check.
2+
PUBLIC SECTION.
3+
DATA sql_message TYPE string.
24

5+
METHODS constructor
6+
IMPORTING
7+
textid LIKE textid OPTIONAL
8+
sql_message TYPE string OPTIONAL
9+
previous TYPE REF TO cx_root OPTIONAL.
310
ENDCLASS.
411

512
CLASS cx_sql_exception IMPLEMENTATION.
13+
METHOD constructor.
14+
super->constructor(
15+
textid = textid
16+
previous = previous ).
17+
18+
me->sql_message = sql_message.
19+
ENDMETHOD.
620

721
ENDCLASS.

src/date_time/cl_abap_datfm.clas.testclasses.abap

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ CLASS ltcl_test_datfm IMPLEMENTATION.
3737
ex_datint = date_internal_actual
3838
ex_datfmused = format_used_actual ).
3939

40-
cl_abap_unit_assert=>assert_equals( exp = christmas act = date_internal_actual ).
41-
cl_abap_unit_assert=>assert_equals( exp = gregorian_dot_seperated act = format_used_actual ).
40+
cl_abap_unit_assert=>assert_equals(
41+
exp = christmas
42+
act = date_internal_actual ).
43+
cl_abap_unit_assert=>assert_equals(
44+
exp = gregorian_dot_seperated
45+
act = format_used_actual ).
4246
ENDMETHOD.
4347

4448
METHOD acc_conv_ext_to_int_infinity.
@@ -55,8 +59,10 @@ CLASS ltcl_test_datfm IMPLEMENTATION.
5559
ex_datint = date_internal_actual
5660
ex_datfmused = format_used_actual ).
5761

58-
cl_abap_unit_assert=>assert_equals( exp = infinity act = date_internal_actual ).
59-
cl_abap_unit_assert=>assert_equals( exp = gregorian_dot_seperated act = format_used_actual ).
62+
cl_abap_unit_assert=>assert_equals( exp = infinity
63+
act = date_internal_actual ).
64+
cl_abap_unit_assert=>assert_equals( exp = gregorian_dot_seperated
65+
act = format_used_actual ).
6066
ENDMETHOD.
6167

6268
METHOD acc_conv_ext_to_int_initial.
@@ -73,8 +79,10 @@ CLASS ltcl_test_datfm IMPLEMENTATION.
7379
ex_datint = date_internal_actual
7480
ex_datfmused = format_used_actual ).
7581

76-
cl_abap_unit_assert=>assert_equals( exp = initial act = date_internal_actual ).
77-
cl_abap_unit_assert=>assert_equals( exp = gregorian_dot_seperated act = format_used_actual ).
82+
cl_abap_unit_assert=>assert_equals( exp = initial
83+
act = date_internal_actual ).
84+
cl_abap_unit_assert=>assert_equals( exp = gregorian_dot_seperated
85+
act = format_used_actual ).
7886
ENDMETHOD.
7987

8088

src/http/cl_http_utility.clas.abap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ CLASS cl_http_utility IMPLEMENTATION.
111111
str = ls_field-name && '=' && ls_field-value.
112112
APPEND str TO tab.
113113
ENDLOOP.
114-
string = concat_lines_of( table = tab sep = '&' ).
114+
string = concat_lines_of( table = tab
115+
sep = '&' ).
115116
ENDMETHOD.
116117

117118
METHOD encode_x_base64.

src/ixml/cl_ixml.clas.locals_imp.abap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ CLASS lcl_node IMPLEMENTATION.
410410
li_children = if_ixml_node~get_children( ).
411411

412412
IF mv_name <> '#text' AND ostream->get_pretty_print( ) = abap_true.
413-
ostream->write_string( repeat( val = | | occ = ostream->get_indent( ) ) ).
413+
ostream->write_string( repeat( val = | |
414+
occ = ostream->get_indent( ) ) ).
414415
ENDIF.
415416

416417
IF mv_name <> '#text'.
@@ -439,7 +440,8 @@ CLASS lcl_node IMPLEMENTATION.
439440
ostream->write_string( lcl_escape=>escape_value( mv_value ) ).
440441
IF mv_name <> '#text'.
441442
IF ostream->get_pretty_print( ) = abap_true AND has_direct_text( ) = abap_false.
442-
ostream->write_string( repeat( val = | | occ = ostream->get_indent( ) ) ).
443+
ostream->write_string( repeat( val = | |
444+
occ = ostream->get_indent( ) ) ).
443445
ENDIF.
444446
ostream->write_string( '</' && lv_ns && mv_name && '>' ).
445447
ENDIF.

0 commit comments

Comments
 (0)