From 5a9d6b4acac39c81b33dba162c4bf6fa5eb4c196 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 00:16:19 +0530 Subject: [PATCH 01/16] [Automated] Update native jar versions in toml files --- ballerina/Ballerina.toml | 8 ++++---- ballerina/CompilerPlugin.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 29f343e..99b83b7 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -21,11 +21,11 @@ path = "../native/build/libs/persist.sql-native-1.4.0-SNAPSHOT.jar" [[platform.java17.dependency]] groupId = "io.ballerina.stdlib" artifactId = "persist-native" -version = "1.4.0" -path = "./lib/persist-native-1.4.0-20240808-102300-3b855e5.jar" +version = "1.3.0" +path = "./lib/persist-native-1.3.0.jar" [[platform.java17.dependency]] groupId = "io.ballerina.stdlib" artifactId = "sql-native" -version = "1.14.0-20240809-142900-0689c89" -path = "./lib/sql-native-1.14.0-20240809-142900-0689c89.jar" +version = "1.13.0" +path = "./lib/sql-native-1.13.0.jar" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index b88094f..0ed7b40 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -6,7 +6,7 @@ class = "io.ballerina.stdlib.persist.sql.compiler.PersistSqlCompilerPlugin" path = "../compiler-plugin/build/libs/persist.sql-compiler-plugin-1.4.0-SNAPSHOT.jar" [[dependency]] -path = "./lib/persist-native-1.4.0-20240808-102300-3b855e5.jar" +path = "./lib/persist-native-1.3.0.jar" [[dependency]] -path = "./lib/persist-compiler-plugin-1.4.0-20240808-102300-3b855e5.jar" +path = "./lib/persist-compiler-plugin-1.3.0.jar" From c61fe4e58adc239acaf12b2d65e9e7517dae991a Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 00:51:49 +0530 Subject: [PATCH 02/16] [Automated] Update native jar versions in toml files --- ballerina/Dependencies.toml | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index de35e16..7b08fb6 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0-20240806-083400-aabac46a" +distribution-version = "2201.10.0-20240529-103800-249ab1b0" [[package]] org = "ballerina" name = "auth" -version = "2.12.0" +version = "2.11.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, @@ -54,7 +54,7 @@ dependencies = [ [[package]] org = "ballerina" name = "file" -version = "1.10.0" +version = "1.9.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -66,7 +66,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.12.0" +version = "2.11.3" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -112,12 +112,11 @@ modules = [ [[package]] org = "ballerina" name = "jwt" -version = "2.13.0" +version = "2.12.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.int"}, {org = "ballerina", name = "lang.string"}, @@ -227,7 +226,7 @@ dependencies = [ [[package]] org = "ballerina" name = "log" -version = "2.10.0" +version = "2.9.0" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -241,19 +240,18 @@ modules = [ [[package]] org = "ballerina" name = "mime" -version = "2.10.0" +version = "2.9.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.int"}, - {org = "ballerina", name = "log"} + {org = "ballerina", name = "lang.int"} ] [[package]] org = "ballerina" name = "oauth2" -version = "2.12.0" +version = "2.11.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "cache"}, @@ -267,7 +265,7 @@ dependencies = [ [[package]] org = "ballerina" name = "observe" -version = "1.3.0" +version = "1.2.3" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -285,7 +283,7 @@ dependencies = [ [[package]] org = "ballerina" name = "persist" -version = "1.4.0" +version = "1.3.0" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -296,7 +294,7 @@ modules = [ [[package]] org = "ballerina" name = "sql" -version = "1.14.0" +version = "1.13.2" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -397,7 +395,7 @@ modules = [ [[package]] org = "ballerinax" name = "java.jdbc" -version = "1.12.0" +version = "2.0.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -413,7 +411,7 @@ modules = [ [[package]] org = "ballerinax" name = "mssql" -version = "1.13.0" +version = "1.12.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, @@ -437,7 +435,7 @@ modules = [ [[package]] org = "ballerinax" name = "mysql" -version = "1.13.0" +version = "1.12.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, @@ -487,7 +485,7 @@ modules = [ [[package]] org = "ballerinax" name = "postgresql" -version = "1.13.0" +version = "1.12.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, From 9bd452f12dfbaa3e15b39141394997f5d957bbef Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 08:58:37 +0530 Subject: [PATCH 03/16] [Automated] Update native jar versions in toml files --- ballerina/Dependencies.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 7b08fb6..eed1618 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -100,6 +100,9 @@ dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.value"} ] +modules = [ + {org = "ballerina", packageName = "io", moduleName = "io"} +] [[package]] org = "ballerina" @@ -462,6 +465,7 @@ org = "ballerinax" name = "persist.sql" version = "1.4.0" dependencies = [ + {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "log"}, {org = "ballerina", name = "persist"}, From 84683d5e94ab22d947ccb3c2a3548e723cd90deb Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 12:25:39 +0530 Subject: [PATCH 04/16] [Automated] Update native jar versions in toml files --- ballerina/Ballerina.toml | 8 ++++---- ballerina/CompilerPlugin.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 99b83b7..29f343e 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -21,11 +21,11 @@ path = "../native/build/libs/persist.sql-native-1.4.0-SNAPSHOT.jar" [[platform.java17.dependency]] groupId = "io.ballerina.stdlib" artifactId = "persist-native" -version = "1.3.0" -path = "./lib/persist-native-1.3.0.jar" +version = "1.4.0" +path = "./lib/persist-native-1.4.0-20240808-102300-3b855e5.jar" [[platform.java17.dependency]] groupId = "io.ballerina.stdlib" artifactId = "sql-native" -version = "1.13.0" -path = "./lib/sql-native-1.13.0.jar" +version = "1.14.0-20240809-142900-0689c89" +path = "./lib/sql-native-1.14.0-20240809-142900-0689c89.jar" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 0ed7b40..b88094f 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -6,7 +6,7 @@ class = "io.ballerina.stdlib.persist.sql.compiler.PersistSqlCompilerPlugin" path = "../compiler-plugin/build/libs/persist.sql-compiler-plugin-1.4.0-SNAPSHOT.jar" [[dependency]] -path = "./lib/persist-native-1.3.0.jar" +path = "./lib/persist-native-1.4.0-20240808-102300-3b855e5.jar" [[dependency]] -path = "./lib/persist-compiler-plugin-1.3.0.jar" +path = "./lib/persist-compiler-plugin-1.4.0-20240808-102300-3b855e5.jar" From cc542c7d523dc21000a1077907ee9ff92de19357 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 12:34:42 +0530 Subject: [PATCH 05/16] [Automated] Update native jar versions in toml files --- ballerina/Dependencies.toml | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index eed1618..db1b2d4 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0-20240529-103800-249ab1b0" +distribution-version = "2201.10.0-20240806-083400-aabac46a" [[package]] org = "ballerina" name = "auth" -version = "2.11.1" +version = "2.12.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, @@ -54,7 +54,7 @@ dependencies = [ [[package]] org = "ballerina" name = "file" -version = "1.9.0" +version = "1.10.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -66,7 +66,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.11.3" +version = "2.12.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -115,11 +115,12 @@ modules = [ [[package]] org = "ballerina" name = "jwt" -version = "2.12.1" +version = "2.13.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, + {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.int"}, {org = "ballerina", name = "lang.string"}, @@ -229,7 +230,7 @@ dependencies = [ [[package]] org = "ballerina" name = "log" -version = "2.9.0" +version = "2.10.0" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -243,18 +244,19 @@ modules = [ [[package]] org = "ballerina" name = "mime" -version = "2.9.0" +version = "2.10.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.int"} + {org = "ballerina", name = "lang.int"}, + {org = "ballerina", name = "log"} ] [[package]] org = "ballerina" name = "oauth2" -version = "2.11.0" +version = "2.12.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "cache"}, @@ -268,7 +270,7 @@ dependencies = [ [[package]] org = "ballerina" name = "observe" -version = "1.2.3" +version = "1.3.0" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -286,7 +288,7 @@ dependencies = [ [[package]] org = "ballerina" name = "persist" -version = "1.3.0" +version = "1.4.0" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -297,7 +299,7 @@ modules = [ [[package]] org = "ballerina" name = "sql" -version = "1.13.2" +version = "1.14.0" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -398,7 +400,7 @@ modules = [ [[package]] org = "ballerinax" name = "java.jdbc" -version = "2.0.0" +version = "1.12.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -414,7 +416,7 @@ modules = [ [[package]] org = "ballerinax" name = "mssql" -version = "1.12.0" +version = "1.13.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, @@ -438,7 +440,7 @@ modules = [ [[package]] org = "ballerinax" name = "mysql" -version = "1.12.0" +version = "1.13.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, @@ -489,7 +491,7 @@ modules = [ [[package]] org = "ballerinax" name = "postgresql" -version = "1.12.0" +version = "1.13.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, From 66a1b564856dedeb43b41d45e0836742543663fa Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 12:53:00 +0530 Subject: [PATCH 06/16] [Automated] Update native jar versions in toml files --- ballerina/Dependencies.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index db1b2d4..de35e16 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -100,9 +100,6 @@ dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.value"} ] -modules = [ - {org = "ballerina", packageName = "io", moduleName = "io"} -] [[package]] org = "ballerina" @@ -467,7 +464,6 @@ org = "ballerinax" name = "persist.sql" version = "1.4.0" dependencies = [ - {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "log"}, {org = "ballerina", name = "persist"}, From c59ea6c99a14ce556b986a7c386981fac51edadd Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 13:17:24 +0530 Subject: [PATCH 07/16] Enable the testcasses --- ballerina/tests/mssql-native-tests.bal | 2 +- ballerina/tests/mysql-native-tests.bal | 2 +- ballerina/tests/postgresql-native-tests.bal | 2 +- .../persist/sql/datastore/SQLProcessor.java | 65 ++++++------------- 4 files changed, 23 insertions(+), 48 deletions(-) diff --git a/ballerina/tests/mssql-native-tests.bal b/ballerina/tests/mssql-native-tests.bal index d4fd753..e2bea31 100644 --- a/ballerina/tests/mssql-native-tests.bal +++ b/ballerina/tests/mssql-native-tests.bal @@ -191,7 +191,7 @@ function mssqlNativeQueryComplexTest() returns error? { @test:Config { groups: ["transactions", "mssql", "native"], dependsOn: [mssqlNativeExecuteTestNegative1, mssqlNativeQueryTest, mssqlNativeQueryTestNegative, mssqlNativeQueryComplexTest], - enable: false + enable: true } function mssqlNativeTransactionTest() returns error? { MSSQLRainierClient rainierClient = check new (); diff --git a/ballerina/tests/mysql-native-tests.bal b/ballerina/tests/mysql-native-tests.bal index c69d2f8..c33c977 100644 --- a/ballerina/tests/mysql-native-tests.bal +++ b/ballerina/tests/mysql-native-tests.bal @@ -191,7 +191,7 @@ function mysqlNativeQueryComplexTest() returns error? { @test:Config { groups: ["transactions", "mysql", "native"], dependsOn: [mysqlNativeExecuteTestNegative1, mysqlNativeQueryTest, mysqlNativeQueryTestNegative, mysqlNativeQueryComplexTest], - enable: false + enable: true } function mysqlNativeTransactionTest() returns error? { MySQLRainierClient rainierClient = check new (); diff --git a/ballerina/tests/postgresql-native-tests.bal b/ballerina/tests/postgresql-native-tests.bal index 1a3f4e7..1d409a5 100644 --- a/ballerina/tests/postgresql-native-tests.bal +++ b/ballerina/tests/postgresql-native-tests.bal @@ -191,7 +191,7 @@ function postgresqlNativeQueryComplexTest() returns error? { @test:Config { groups: ["transactions", "postgresql", "native"], dependsOn: [postgresqlNativeExecuteTestNegative1, postgresqlNativeQueryTest, postgresqlNativeQueryTestNegative, postgresqlNativeQueryComplexTest], - enable: false + enable: true } function postgresqlNativeTransactionTest() returns error? { PostgreSQLRainierClient rainierClient = check new (); diff --git a/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java b/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java index 11baf06..b614883 100644 --- a/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.async.Callback; +import io.ballerina.runtime.api.constants.RuntimeConstants; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.ErrorType; @@ -36,13 +37,13 @@ import io.ballerina.runtime.api.values.BStream; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.api.values.BTypedesc; +import io.ballerina.runtime.transactions.TransactionLocalContext; import io.ballerina.runtime.transactions.TransactionResourceManager; import io.ballerina.stdlib.persist.Constants; import io.ballerina.stdlib.persist.ModuleUtils; import io.ballerina.stdlib.persist.sql.Utils; -import io.ballerina.stdlib.sql.parameterprocessor.DefaultResultParameterProcessor; -import io.ballerina.stdlib.sql.parameterprocessor.DefaultStatementParameterProcessor; +import java.util.HashMap; import java.util.Map; import static io.ballerina.stdlib.persist.Constants.ERROR; @@ -180,50 +181,12 @@ public void notifyFailure(BError bError) { static BStream queryNativeSQL(Environment env, BObject client, BObject paramSQLString, BTypedesc targetType) { // This method will return `stream` - - TransactionResourceManager trxResourceManager = TransactionResourceManager.getInstance(); - if (!io.ballerina.stdlib.sql.utils.Utils.isWithinTrxBlock(trxResourceManager)) { - return queryNativeSQLBal(env, client, paramSQLString, targetType); - } - - BObject dbClient = (BObject) client.get(DB_CLIENT); - BStream sqlStream = io.ballerina.stdlib.sql.nativeimpl.QueryProcessor.nativeQuery(env, dbClient, - paramSQLString, targetType, DefaultStatementParameterProcessor.getInstance(), - DefaultResultParameterProcessor.getInstance()); - - if (sqlStream != null) { - BObject persistNativeStream = createPersistNativeSQLStream(sqlStream, null); - RecordType streamConstraint = - (RecordType) TypeUtils.getReferredType(targetType.getDescribingType()); - return (ValueCreator.createStreamValue(TypeCreator.createStreamType(streamConstraint, - PredefinedTypes.TYPE_NULL), persistNativeStream) - ); - } - - return null; + return queryNativeSQLBal(env, client, paramSQLString, targetType); } static Object executeNativeSQL(Environment env, BObject client, BObject paramSQLString) { // This method will return `persist:ExecutionResult|persist:Error` - - TransactionResourceManager trxResourceManager = TransactionResourceManager.getInstance(); - if (!io.ballerina.stdlib.sql.utils.Utils.isWithinTrxBlock(trxResourceManager)) { - return executeNativeSQLBal(env, client, paramSQLString); - } - - BObject dbClient = (BObject) client.get(DB_CLIENT); - Object sqlExecutionResult = io.ballerina.stdlib.sql.nativeimpl.ExecuteProcessor.nativeExecute(env, dbClient, - paramSQLString, DefaultStatementParameterProcessor.getInstance()); - - if (sqlExecutionResult instanceof BMap) { // returned type is `sql:ExecutionResult` - return ValueCreator.createRecordValue(getModule(), - io.ballerina.stdlib.persist.sql.Constants.PERSIST_EXECUTION_RESULT, - (BMap) sqlExecutionResult); - } else if (sqlExecutionResult instanceof BError) { // returned type is `sql:Error` - return wrapSQLError((BError) sqlExecutionResult); - } - - return null; + return executeNativeSQLBal(env, client, paramSQLString); } private static BStream queryNativeSQLBal(Environment env, BObject client, BObject paramSQLString, @@ -233,6 +196,12 @@ private static BStream queryNativeSQLBal(Environment env, BObject client, BObjec BObject dbClient = (BObject) client.get(DB_CLIENT); RecordType recordType = (RecordType) targetType.getDescribingType(); StreamType streamType = TypeCreator.createStreamType(recordType, PredefinedTypes.TYPE_NULL); + TransactionResourceManager trxResourceManager = TransactionResourceManager.getInstance(); + TransactionLocalContext currentTrxContext = trxResourceManager.getCurrentTransactionContext(); + Map properties = new HashMap<>(); + if (currentTrxContext != null) { + properties = Map.of(RuntimeConstants.CURRENT_TRANSACTION_CONTEXT_PROPERTY, currentTrxContext); + } Future balFuture = env.markAsync(); env.getRuntime().invokeMethodAsyncSequentially( @@ -257,7 +226,7 @@ public void notifyFailure(BError bError) { // can only be hit on a panic BObject errorStream = Utils.createPersistNativeSQLStream(null, bError); balFuture.complete(errorStream); } - }, null, streamType, paramSQLString, true, targetType, true + }, properties, streamType, paramSQLString, true, targetType, true ); return null; @@ -267,6 +236,12 @@ private static Object executeNativeSQLBal(Environment env, BObject client, BObje BObject dbClient = (BObject) client.get(DB_CLIENT); RecordType persistExecutionResultType = TypeCreator.createRecordType( io.ballerina.stdlib.persist.sql.Constants.PERSIST_EXECUTION_RESULT, getModule(), 0, true, 0); + TransactionResourceManager trxResourceManager = TransactionResourceManager.getInstance(); + TransactionLocalContext currentTrxContext = trxResourceManager.getCurrentTransactionContext(); + Map properties = new HashMap<>(); + if (currentTrxContext != null) { + properties = Map.of(RuntimeConstants.CURRENT_TRANSACTION_CONTEXT_PROPERTY, currentTrxContext); + } Future balFuture = env.markAsync(); env.getRuntime().invokeMethodAsyncSequentially( @@ -292,8 +267,8 @@ public void notifyFailure(BError bError) { // can only be hit on a panic BError persistError = wrapError(bError); balFuture.complete(persistError); } - }, null, persistExecutionResultType, paramSQLString, true - ); + }, properties, + persistExecutionResultType, paramSQLString, true); return null; } From 7b03a301ada9ceac0a46e6f567cd4787e3471f32 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 13:23:00 +0530 Subject: [PATCH 08/16] Enable h2 db transaction test --- ballerina/tests/h2-native-tests.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/tests/h2-native-tests.bal b/ballerina/tests/h2-native-tests.bal index 5d68b4b..71be072 100644 --- a/ballerina/tests/h2-native-tests.bal +++ b/ballerina/tests/h2-native-tests.bal @@ -191,7 +191,7 @@ function h2NativeQueryComplexTest() returns error? { @test:Config { groups: ["transactions", "h2", "native"], dependsOn: [h2NativeExecuteTestNegative1, h2NativeQueryTest, h2NativeQueryTestNegative, h2NativeQueryComplexTest], - enable: false + enable: true } function h2NativeTransactionTest() returns error? { H2RainierClient rainierClient = check new (); From 12ccf0eadbe162b64e3d7fc7db7bdd5cb126c124 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 13:41:55 +0530 Subject: [PATCH 09/16] properties set to null when txn not exists --- .../ballerina/stdlib/persist/sql/datastore/SQLProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java b/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java index b614883..3453910 100644 --- a/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java @@ -198,7 +198,7 @@ private static BStream queryNativeSQLBal(Environment env, BObject client, BObjec StreamType streamType = TypeCreator.createStreamType(recordType, PredefinedTypes.TYPE_NULL); TransactionResourceManager trxResourceManager = TransactionResourceManager.getInstance(); TransactionLocalContext currentTrxContext = trxResourceManager.getCurrentTransactionContext(); - Map properties = new HashMap<>(); + Map properties = null; if (currentTrxContext != null) { properties = Map.of(RuntimeConstants.CURRENT_TRANSACTION_CONTEXT_PROPERTY, currentTrxContext); } @@ -238,7 +238,7 @@ private static Object executeNativeSQLBal(Environment env, BObject client, BObje io.ballerina.stdlib.persist.sql.Constants.PERSIST_EXECUTION_RESULT, getModule(), 0, true, 0); TransactionResourceManager trxResourceManager = TransactionResourceManager.getInstance(); TransactionLocalContext currentTrxContext = trxResourceManager.getCurrentTransactionContext(); - Map properties = new HashMap<>(); + Map properties = null; if (currentTrxContext != null) { properties = Map.of(RuntimeConstants.CURRENT_TRANSACTION_CONTEXT_PROPERTY, currentTrxContext); } From bb8439b36a16dde31d76676afeb572100ddfb32e Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 13:45:16 +0530 Subject: [PATCH 10/16] remove unused import --- .../io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java b/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java index 3453910..1e60172 100644 --- a/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java @@ -43,7 +43,6 @@ import io.ballerina.stdlib.persist.ModuleUtils; import io.ballerina.stdlib.persist.sql.Utils; -import java.util.HashMap; import java.util.Map; import static io.ballerina.stdlib.persist.Constants.ERROR; From d105515ee8b8ce6d0aa0be406dad6f0014fe8f5f Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 17:17:33 +0530 Subject: [PATCH 11/16] [Automated] Update native jar versions in toml files --- ballerina/Dependencies.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index de35e16..db1b2d4 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -100,6 +100,9 @@ dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.value"} ] +modules = [ + {org = "ballerina", packageName = "io", moduleName = "io"} +] [[package]] org = "ballerina" @@ -464,6 +467,7 @@ org = "ballerinax" name = "persist.sql" version = "1.4.0" dependencies = [ + {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "log"}, {org = "ballerina", name = "persist"}, From d12380fd49865b777a3ff9225cd33698d4cf132f Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 18:02:13 +0530 Subject: [PATCH 12/16] change the h2 native test case --- ballerina/tests/h2-native-tests.bal | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ballerina/tests/h2-native-tests.bal b/ballerina/tests/h2-native-tests.bal index 71be072..8bf63c4 100644 --- a/ballerina/tests/h2-native-tests.bal +++ b/ballerina/tests/h2-native-tests.bal @@ -16,6 +16,7 @@ import ballerina/test; import ballerina/persist; +import ballerina/io; @test:Config { groups: ["native", "h2"], @@ -254,17 +255,14 @@ function h2NativeTransactionTest2() returns error? { check buildingStream.close(); test:assertEquals(buildings, [building33]); - transaction { - _ = check rainierClient->executeNativeSQL(` - UPDATE "Building" - SET - "city" = ${building33Updated.city}, - "state" = ${building33Updated.state}, - "country" = ${building33Updated.country} - WHERE "buildingCode" = ${building33.buildingCode} - `); - check commit; - } + _ = check rainierClient->executeNativeSQL(` + UPDATE "Building" + SET + "city" = ${building33Updated.city}, + "state" = ${building33Updated.state}, + "country" = ${building33Updated.country} + WHERE "buildingCode" = ${building33.buildingCode} + `); stream buildingStream3 = rainierClient->queryNativeSQL(`SELECT * FROM "Building" WHERE "buildingCode" = ${building33.buildingCode}`); Building[] buildings3 = check from Building building in buildingStream3 From 046bc510bc20c2ecf5fa879ebf161f73a6b686bc Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 18:03:29 +0530 Subject: [PATCH 13/16] remove unused imports --- ballerina/tests/h2-native-tests.bal | 1 - 1 file changed, 1 deletion(-) diff --git a/ballerina/tests/h2-native-tests.bal b/ballerina/tests/h2-native-tests.bal index 8bf63c4..7174efb 100644 --- a/ballerina/tests/h2-native-tests.bal +++ b/ballerina/tests/h2-native-tests.bal @@ -16,7 +16,6 @@ import ballerina/test; import ballerina/persist; -import ballerina/io; @test:Config { groups: ["native", "h2"], From e3d433eb371605ee605d79c772bd553c9b9380c7 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 18:05:58 +0530 Subject: [PATCH 14/16] [Automated] Update native jar versions in toml files --- ballerina/Dependencies.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index db1b2d4..de35e16 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -100,9 +100,6 @@ dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.value"} ] -modules = [ - {org = "ballerina", packageName = "io", moduleName = "io"} -] [[package]] org = "ballerina" @@ -467,7 +464,6 @@ org = "ballerinax" name = "persist.sql" version = "1.4.0" dependencies = [ - {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "log"}, {org = "ballerina", name = "persist"}, From 48bab60477712203de468102d9702cf070fd0043 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 18:14:38 +0530 Subject: [PATCH 15/16] remove transaction block as there are one action --- ballerina/tests/mssql-native-tests.bal | 19 ++++++++----------- ballerina/tests/mysql-native-tests.bal | 19 ++++++++----------- ballerina/tests/postgresql-native-tests.bal | 19 ++++++++----------- 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/ballerina/tests/mssql-native-tests.bal b/ballerina/tests/mssql-native-tests.bal index e2bea31..3d06f9e 100644 --- a/ballerina/tests/mssql-native-tests.bal +++ b/ballerina/tests/mssql-native-tests.bal @@ -254,17 +254,14 @@ function mssqlNativeTransactionTest2() returns error? { check buildingStream.close(); test:assertEquals(buildings, [building33]); - transaction { - _ = check rainierClient->executeNativeSQL(` - UPDATE Building - SET - city = ${building33Updated.city}, - state = ${building33Updated.state}, - country = ${building33Updated.country} - WHERE buildingCode = ${building33.buildingCode} - `); - check commit; - } + _ = check rainierClient->executeNativeSQL(` + UPDATE Building + SET + city = ${building33Updated.city}, + state = ${building33Updated.state}, + country = ${building33Updated.country} + WHERE buildingCode = ${building33.buildingCode} + `); stream buildingStream3 = rainierClient->queryNativeSQL(`SELECT * FROM Building WHERE buildingCode = ${building33.buildingCode}`); Building[] buildings3 = check from Building building in buildingStream3 diff --git a/ballerina/tests/mysql-native-tests.bal b/ballerina/tests/mysql-native-tests.bal index c33c977..4a7e145 100644 --- a/ballerina/tests/mysql-native-tests.bal +++ b/ballerina/tests/mysql-native-tests.bal @@ -254,17 +254,14 @@ function mysqlNativeTransactionTest2() returns error? { check buildingStream.close(); test:assertEquals(buildings, [building33]); - transaction { - _ = check rainierClient->executeNativeSQL(` - UPDATE Building - SET - city = ${building33Updated.city}, - state = ${building33Updated.state}, - country = ${building33Updated.country} - WHERE buildingCode = ${building33.buildingCode} - `); - check commit; - } + _ = check rainierClient->executeNativeSQL(` + UPDATE Building + SET + city = ${building33Updated.city}, + state = ${building33Updated.state}, + country = ${building33Updated.country} + WHERE buildingCode = ${building33.buildingCode} + `); stream buildingStream3 = rainierClient->queryNativeSQL(`SELECT * FROM Building WHERE buildingCode = ${building33.buildingCode}`); Building[] buildings3 = check from Building building in buildingStream3 diff --git a/ballerina/tests/postgresql-native-tests.bal b/ballerina/tests/postgresql-native-tests.bal index 1d409a5..f309071 100644 --- a/ballerina/tests/postgresql-native-tests.bal +++ b/ballerina/tests/postgresql-native-tests.bal @@ -254,17 +254,14 @@ function postgresqlNativeTransactionTest2() returns error? { check buildingStream.close(); test:assertEquals(buildings, [building33]); - transaction { - _ = check rainierClient->executeNativeSQL(` - UPDATE "Building" - SET - "city" = ${building33Updated.city}, - "state" = ${building33Updated.state}, - "country" = ${building33Updated.country} - WHERE "buildingCode" = ${building33.buildingCode} - `); - check commit; - } + _ = check rainierClient->executeNativeSQL(` + UPDATE "Building" + SET + "city" = ${building33Updated.city}, + "state" = ${building33Updated.state}, + "country" = ${building33Updated.country} + WHERE "buildingCode" = ${building33.buildingCode} + `); stream buildingStream3 = rainierClient->queryNativeSQL(`SELECT * FROM "Building" WHERE "buildingCode" = ${building33.buildingCode}`); Building[] buildings3 = check from Building building in buildingStream3 From 2dc83b518447adc18efb99faf1b2a8784f28d3d8 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 12 Aug 2024 18:15:30 +0530 Subject: [PATCH 16/16] Update native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java --- .../ballerina/stdlib/persist/sql/datastore/SQLProcessor.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java b/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java index 1e60172..942441e 100644 --- a/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/persist/sql/datastore/SQLProcessor.java @@ -266,8 +266,7 @@ public void notifyFailure(BError bError) { // can only be hit on a panic BError persistError = wrapError(bError); balFuture.complete(persistError); } - }, properties, - persistExecutionResultType, paramSQLString, true); + }, properties, persistExecutionResultType, paramSQLString, true); return null; }