From 0854523871e0badce4c1722366d6e7a20d9f9dae Mon Sep 17 00:00:00 2001 From: niveathika Date: Sat, 14 Oct 2023 10:19:01 +0530 Subject: [PATCH 01/10] Revert "Merge pull request #411 from niveathika/support-backtick" This reverts commit b9cf5c006ca602d41c9a3f8dfdfa860e17891bf3, reversing changes made to 49d0d487a78bf1f9acc4d48256ffda54461d5588. --- build-config/spotbugs-exclude.xml | 9 ----- changelog.md | 5 +++ .../io/ballerina/stdlib/sql/Constants.java | 1 - .../stdlib/sql/ParameterizedQuery.java | 39 ------------------- .../stdlib/sql/nativeimpl/CallProcessor.java | 21 +++++----- .../sql/nativeimpl/ExecuteProcessor.java | 22 +++++------ .../stdlib/sql/nativeimpl/QueryProcessor.java | 14 +++---- .../AbstractStatementParameterProcessor.java | 9 +++-- .../io/ballerina/stdlib/sql/utils/Utils.java | 23 ++++------- .../io/ballerina/stdlib/sql/TestUtils.java | 2 +- .../ballerina/stdlib/sql/utils/UtilsTest.java | 25 ------------ 11 files changed, 46 insertions(+), 124 deletions(-) delete mode 100644 native/src/main/java/io/ballerina/stdlib/sql/ParameterizedQuery.java diff --git a/build-config/spotbugs-exclude.xml b/build-config/spotbugs-exclude.xml index 9462f0a99..9e424c126 100644 --- a/build-config/spotbugs-exclude.xml +++ b/build-config/spotbugs-exclude.xml @@ -39,15 +39,6 @@ - - - - - - - - - diff --git a/changelog.md b/changelog.md index 58c29783d..6d4363d34 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - [Support retrieval of enum types](https://github.com/ballerina-platform/ballerina-standard-library/issues/4588) +## [1.9.1] + +### Changed +- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) + ## [1.9.0] - 2023-06-01 ### Changed diff --git a/native/src/main/java/io/ballerina/stdlib/sql/Constants.java b/native/src/main/java/io/ballerina/stdlib/sql/Constants.java index eb98c99ce..92dfeaf79 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/Constants.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/Constants.java @@ -77,7 +77,6 @@ private Constants() { public static final String PASSWORD = "password"; public static final String ANNON_RECORD_TYPE_NAME = "record {"; - public static final String BACKTICK = "`"; public static final String DEFAULT_STREAM_CONSTRAINT_NAME = "$stream$anon$constraint$"; public static final String INHERENT_TYPE_VIOLATION = "{ballerina/lang.map}InherentTypeViolation"; /** diff --git a/native/src/main/java/io/ballerina/stdlib/sql/ParameterizedQuery.java b/native/src/main/java/io/ballerina/stdlib/sql/ParameterizedQuery.java deleted file mode 100644 index eaddbd39c..000000000 --- a/native/src/main/java/io/ballerina/stdlib/sql/ParameterizedQuery.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.stdlib.sql; - -/** - * Processed Details from sql:ParameterizedQuery. - */ -public class ParameterizedQuery { - private final String sqlQuery; - private final Object[] insertions; - - public ParameterizedQuery(String sqlQuery, Object[] insertions) { - this.sqlQuery = sqlQuery; - this.insertions = insertions; - } - - public String getSqlQuery() { - return sqlQuery; - } - - public Object[] getInsertions() { - return insertions; - } -} diff --git a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/CallProcessor.java b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/CallProcessor.java index 2df7b5d70..17d8d70ac 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/CallProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/CallProcessor.java @@ -32,7 +32,6 @@ import io.ballerina.runtime.api.values.BTypedesc; import io.ballerina.runtime.transactions.TransactionResourceManager; import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.datasource.SQLDatasource; import io.ballerina.stdlib.sql.exception.ApplicationError; import io.ballerina.stdlib.sql.parameterprocessor.AbstractResultParameterProcessor; @@ -62,6 +61,7 @@ import static io.ballerina.stdlib.sql.datasource.SQLWorkerThreadPool.SQL_EXECUTOR_SERVICE; import static io.ballerina.stdlib.sql.utils.Utils.getColumnDefinitions; import static io.ballerina.stdlib.sql.utils.Utils.getDefaultStreamConstraint; +import static io.ballerina.stdlib.sql.utils.Utils.getSqlQuery; import static io.ballerina.stdlib.sql.utils.Utils.updateProcedureCallExecutionResult; /** @@ -121,13 +121,12 @@ private static Object nativeCallExecutable(BObject client, BObject paramSQLStrin ResultSet resultSet; String sqlQuery = null; try { - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(paramSQLString); - sqlQuery = parameterizedQuery.getSqlQuery(); + sqlQuery = getSqlQuery(paramSQLString); connection = SQLDatasource.getConnection(isWithinTrxBlock, trxResourceManager, client, sqlDatasource); statement = connection.prepareCall(sqlQuery); HashMap outputParamTypes = new HashMap<>(); - setCallParameters(connection, statement, parameterizedQuery.getInsertions(), outputParamTypes, + setCallParameters(connection, statement, paramSQLString, outputParamTypes, statementParameterProcessor); boolean resultType = statement.execute(); @@ -159,7 +158,7 @@ private static Object nativeCallExecutable(BObject client, BObject paramSQLStrin updateProcedureCallExecutionResult(statement, procedureCallResult); } - populateOutParameters(statement, parameterizedQuery.getInsertions(), outputParamTypes, + populateOutParameters(statement, paramSQLString, outputParamTypes, resultParameterProcessor); procedureCallResult.addNativeData(STATEMENT_NATIVE_DATA_FIELD, statement); @@ -182,11 +181,12 @@ private static Object nativeCallExecutable(BObject client, BObject paramSQLStrin } private static void setCallParameters(Connection connection, CallableStatement statement, - Object[] insertions, HashMap outputParamTypes, + BObject paramString, HashMap outputParamTypes, AbstractStatementParameterProcessor statementParameterProcessor) throws SQLException, ApplicationError { - for (int i = 0; i < insertions.length; i++) { - Object object = insertions[i]; + BArray arrayValue = paramString.getArrayValue(Constants.ParameterizedQueryFields.INSERTIONS); + for (int i = 0; i < arrayValue.size(); i++) { + Object object = arrayValue.get(i); int index = i + 1; if (object instanceof BObject) { BObject objectValue = (BObject) object; @@ -225,19 +225,20 @@ private static void setCallParameters(Connection connection, CallableStatement s } } - private static void populateOutParameters(CallableStatement statement, Object[] insertions, + private static void populateOutParameters(CallableStatement statement, BObject paramSQLString, HashMap outputParamTypes, AbstractResultParameterProcessor resultParameterProcessor) throws SQLException, ApplicationError { if (outputParamTypes.size() == 0) { return; } + BArray arrayValue = paramSQLString.getArrayValue(Constants.ParameterizedQueryFields.INSERTIONS); for (Map.Entry entry : outputParamTypes.entrySet()) { int paramIndex = entry.getKey(); int sqlType = entry.getValue(); - BObject parameter = (BObject) insertions[paramIndex - 1]; + BObject parameter = (BObject) arrayValue.get(paramIndex - 1); parameter.addNativeData(Constants.ParameterObject.SQL_TYPE_NATIVE_DATA, sqlType); Object result; diff --git a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/ExecuteProcessor.java b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/ExecuteProcessor.java index 30ff43d2f..a09aacc67 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/ExecuteProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/ExecuteProcessor.java @@ -28,7 +28,6 @@ import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.transactions.TransactionResourceManager; import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.datasource.SQLDatasource; import io.ballerina.stdlib.sql.exception.ApplicationError; import io.ballerina.stdlib.sql.parameterprocessor.AbstractStatementParameterProcessor; @@ -52,6 +51,7 @@ import static io.ballerina.stdlib.sql.datasource.SQLWorkerThreadPool.SQL_EXECUTOR_SERVICE; import static io.ballerina.stdlib.sql.utils.Utils.closeResources; import static io.ballerina.stdlib.sql.utils.Utils.getGeneratedKeys; +import static io.ballerina.stdlib.sql.utils.Utils.getSqlQuery; /** @@ -104,8 +104,7 @@ private static Object nativeExecuteExecutable(BObject client, BObject paramSQLSt ResultSet resultSet = null; String sqlQuery = null; try { - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(paramSQLString); - sqlQuery = parameterizedQuery.getSqlQuery(); + sqlQuery = getSqlQuery(paramSQLString); connection = SQLDatasource.getConnection(isWithInTrxBlock, trxResourceManager, client, sqlDatasource); if (sqlDatasource.getExecuteGKFlag()) { @@ -114,7 +113,7 @@ private static Object nativeExecuteExecutable(BObject client, BObject paramSQLSt statement = connection.prepareStatement(sqlQuery); } - statementParameterProcessor.setParams(connection, statement, parameterizedQuery.getInsertions()); + statementParameterProcessor.setParams(connection, statement, paramSQLString); int count = statement.executeUpdate(); Object lastInsertedId = null; @@ -184,19 +183,20 @@ private static Object nativeBatchExecuteExecutable(BObject client, BArray paramS Connection connection = null; PreparedStatement statement = null; String sqlQuery = null; - List parameters = new ArrayList<>(); + List parameters = new ArrayList<>(); List> executionResults = new ArrayList<>(); boolean processResultSet = false; int batchSize = 1000; try { Object[] paramSQLObjects = paramSQLStrings.getValues(); - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(((BObject) paramSQLObjects[0])); - sqlQuery = parameterizedQuery.getSqlQuery(); - parameters.add(parameterizedQuery.getInsertions()); + BObject parameterizedQuery = (BObject) paramSQLObjects[0]; + sqlQuery = getSqlQuery(parameterizedQuery); + parameters.add(parameterizedQuery); for (int paramIndex = 1; paramIndex < paramSQLStrings.size(); paramIndex++) { - parameterizedQuery = Utils.getParameterizedSQLQuery(((BObject) paramSQLObjects[paramIndex])); - if (sqlQuery.equals(parameterizedQuery.getSqlQuery())) { - parameters.add(parameterizedQuery.getInsertions()); + parameterizedQuery = (BObject) paramSQLObjects[paramIndex]; + String paramSQLQuery = getSqlQuery(parameterizedQuery); + if (sqlQuery.equals(paramSQLQuery)) { + parameters.add(parameterizedQuery); } else { return ErrorGenerator.getSQLApplicationError("Batch Execute cannot contain different SQL " + "commands. These has to be executed in different function calls"); diff --git a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/QueryProcessor.java b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/QueryProcessor.java index 4f31e0d67..b36621956 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/QueryProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/QueryProcessor.java @@ -36,7 +36,6 @@ import io.ballerina.runtime.api.values.BTypedesc; import io.ballerina.runtime.transactions.TransactionResourceManager; import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.datasource.SQLDatasource; import io.ballerina.stdlib.sql.exception.ApplicationError; import io.ballerina.stdlib.sql.exception.DataError; @@ -115,11 +114,10 @@ private static BStream nativeQueryExecutable( ResultSet resultSet = null; String sqlQuery = null; try { - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(paramSQLString); - sqlQuery = parameterizedQuery.getSqlQuery(); + sqlQuery = Utils.getSqlQuery(paramSQLString); connection = SQLDatasource.getConnection(isWithInTrxBlock, trxResourceManager, client, sqlDatasource); statement = connection.prepareStatement(sqlQuery); - statementParameterProcessor.setParams(connection, statement, parameterizedQuery.getInsertions()); + statementParameterProcessor.setParams(connection, statement, paramSQLString); resultSet = statement.executeQuery(); RecordType streamConstraint = (RecordType) TypeUtils.getReferredType( ((BTypedesc) recordType).getDescribingType()); @@ -172,7 +170,8 @@ public static Object nativeQueryRow(Environment env, BObject client, BObject par } private static Object nativeQueryRowExecutable( - BObject client, BObject paramSQLString, BTypedesc ballerinaType, + BObject client, BObject paramSQLString, + BTypedesc ballerinaType, AbstractStatementParameterProcessor statementParameterProcessor, AbstractResultParameterProcessor resultParameterProcessor, boolean isWithInTrxBlock, TransactionResourceManager trxResourceManager) { @@ -189,11 +188,10 @@ private static Object nativeQueryRowExecutable( ResultSet resultSet = null; String sqlQuery = null; try { - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(paramSQLString); - sqlQuery = parameterizedQuery.getSqlQuery(); + sqlQuery = Utils.getSqlQuery(paramSQLString); connection = SQLDatasource.getConnection(isWithInTrxBlock, trxResourceManager, client, sqlDatasource); statement = connection.prepareStatement(sqlQuery); - statementParameterProcessor.setParams(connection, statement, parameterizedQuery.getInsertions()); + statementParameterProcessor.setParams(connection, statement, paramSQLString); resultSet = statement.executeQuery(); if (!resultSet.next()) { return ErrorGenerator.getNoRowsError("Query did not retrieve any rows."); diff --git a/native/src/main/java/io/ballerina/stdlib/sql/parameterprocessor/AbstractStatementParameterProcessor.java b/native/src/main/java/io/ballerina/stdlib/sql/parameterprocessor/AbstractStatementParameterProcessor.java index 150d7f30e..260aedeab 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/parameterprocessor/AbstractStatementParameterProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/parameterprocessor/AbstractStatementParameterProcessor.java @@ -197,10 +197,11 @@ protected abstract void setXml(Connection connection, PreparedStatement prepared protected abstract int setCustomBOpenRecord(Connection connection, PreparedStatement preparedStatement, int index, Object value, boolean returnType) throws DataError, SQLException; - public void setParams(Connection connection, PreparedStatement preparedStatement, - Object[] insertions) throws DataError, SQLException { - for (int i = 0; i < insertions.length; i++) { - Object object = insertions[i]; + public void setParams(Connection connection, PreparedStatement preparedStatement, BObject paramString) + throws DataError, SQLException { + BArray arrayValue = paramString.getArrayValue(Constants.ParameterizedQueryFields.INSERTIONS); + for (int i = 0; i < arrayValue.size(); i++) { + Object object = arrayValue.get(i); int index = i + 1; setSQLValueParam(connection, preparedStatement, index, object, false); } diff --git a/native/src/main/java/io/ballerina/stdlib/sql/utils/Utils.java b/native/src/main/java/io/ballerina/stdlib/sql/utils/Utils.java index 0150773b9..c7ba4d4de 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/utils/Utils.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/utils/Utils.java @@ -41,7 +41,6 @@ import io.ballerina.runtime.api.values.BValue; import io.ballerina.runtime.transactions.TransactionResourceManager; import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.exception.ApplicationError; import io.ballerina.stdlib.sql.exception.ConversionError; import io.ballerina.stdlib.sql.exception.DataError; @@ -87,7 +86,6 @@ import static io.ballerina.stdlib.sql.Constants.AFFECTED_ROW_COUNT_FIELD; import static io.ballerina.stdlib.sql.Constants.ANNON_RECORD_TYPE_NAME; import static io.ballerina.stdlib.sql.Constants.ANN_COLUMN_NAME_FIELD; -import static io.ballerina.stdlib.sql.Constants.BACKTICK; import static io.ballerina.stdlib.sql.Constants.COLUMN_ANN_NAME; import static io.ballerina.stdlib.sql.Constants.DEFAULT_STREAM_CONSTRAINT_NAME; import static io.ballerina.stdlib.sql.Constants.EXECUTION_RESULT_FIELD; @@ -158,23 +156,16 @@ public static void closeResources(boolean isWithinTrxBlock, ResultSet resultSet, } } - public static ParameterizedQuery getParameterizedSQLQuery(BObject paramString) { + public static String getSqlQuery(BObject paramString) { + BArray stringsArray = paramString.getArrayValue(Constants.ParameterizedQueryFields.STRINGS); StringBuilder sqlQuery = new StringBuilder(); - List insertions = new ArrayList<>(); - - BArray bStringsArray = paramString.getArrayValue(Constants.ParameterizedQueryFields.STRINGS); - BArray bInsertions = paramString.getArrayValue(Constants.ParameterizedQueryFields.INSERTIONS); - for (int i = 0; i < bInsertions.size(); i++) { - if (bInsertions.get(i) instanceof BString && bInsertions.getBString(i).getValue().equals(BACKTICK)) { - sqlQuery.append(bStringsArray.getBString(i).getValue()).append(BACKTICK); - } else { - insertions.add(bInsertions.get(i)); - sqlQuery.append(bStringsArray.getBString(i).getValue()).append(" ? "); + for (int i = 0; i < stringsArray.size(); i++) { + if (i > 0) { + sqlQuery.append(" ? "); } + sqlQuery.append(stringsArray.get(i).toString()); } - sqlQuery.append(bStringsArray.getBString(bInsertions.size())); - - return new ParameterizedQuery(sqlQuery.toString(), insertions.toArray()); + return sqlQuery.toString(); } public static DataError throwInvalidParameterError(Object value, String sqlType) { diff --git a/native/src/test/java/io/ballerina/stdlib/sql/TestUtils.java b/native/src/test/java/io/ballerina/stdlib/sql/TestUtils.java index 1eedca478..4ed8ded2b 100644 --- a/native/src/test/java/io/ballerina/stdlib/sql/TestUtils.java +++ b/native/src/test/java/io/ballerina/stdlib/sql/TestUtils.java @@ -145,7 +145,7 @@ public BObject getObjectValue(BString bString) { @Override public BArray getArrayValue(BString bString) { - return ((BArray) nativeData.get(bString.getValue())); + return null; } @Override diff --git a/native/src/test/java/io/ballerina/stdlib/sql/utils/UtilsTest.java b/native/src/test/java/io/ballerina/stdlib/sql/utils/UtilsTest.java index a8d3cfec7..dae405b39 100644 --- a/native/src/test/java/io/ballerina/stdlib/sql/utils/UtilsTest.java +++ b/native/src/test/java/io/ballerina/stdlib/sql/utils/UtilsTest.java @@ -18,20 +18,14 @@ package io.ballerina.stdlib.sql.utils; -import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.StructureType; import io.ballerina.runtime.api.utils.TypeUtils; -import io.ballerina.runtime.api.values.BObject; -import io.ballerina.runtime.api.values.BString; -import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.TestUtils; import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; -import static io.ballerina.runtime.api.utils.StringUtils.fromString; import static org.testng.Assert.assertEquals; /** @@ -62,23 +56,4 @@ void getDefaultRecordTypeTest() { StructureType structureType = Utils.getDefaultRecordType(list); assertEquals(structureType.getFlags(), 0); } - - @Test - void backTickEscapeTest() { - // HSQLDB does not support backtick quotes - BObject bParameterizedQuery = TestUtils.getMockObject("parameterizedQuery"); - - BString[] bStrings = {fromString("x"), fromString("y"), fromString("z"), fromString("")}; - - BString[] insertions = {fromString("`"), fromString("abc"), fromString("`") }; - - - bParameterizedQuery.addNativeData(Constants.ParameterizedQueryFields.STRINGS.getValue(), - ValueCreator.createArrayValue(bStrings)); - bParameterizedQuery.addNativeData(Constants.ParameterizedQueryFields.INSERTIONS.getValue(), - ValueCreator.createArrayValue(insertions)); - - ParameterizedQuery parameterizedSQLQuery = Utils.getParameterizedSQLQuery(bParameterizedQuery); - assertEquals(parameterizedSQLQuery.getSqlQuery(), "x`y ? z`"); - } } From 3419fe81174bdfb1dd61b9957f713ab35c2fdb54 Mon Sep 17 00:00:00 2001 From: niveathika Date: Sun, 15 Oct 2023 15:17:21 +0530 Subject: [PATCH 02/10] Sync changelog --- changelog.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 6d4363d34..56217898e 100644 --- a/changelog.md +++ b/changelog.md @@ -9,15 +9,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed -- [Support retrieval of enum types](https://github.com/ballerina-platform/ballerina-standard-library/issues/4588) +- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) + +## [1.11.0] - 2023-09-18 + +### Added +- Support for Java17 + +## [1.10.0] - 2023-06-30 -## [1.9.1] +### Added +- [Support retrieval of enum types](https://github.com/ballerina-platform/ballerina-standard-library/issues/4588) ### Changed -- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) +- [Fix failure for unsupported time type](https://github.com/ballerina-platform/ballerina-standard-library/issues/4531) ## [1.9.0] - 2023-06-01 +### Changed +- Add GraalVM support + +## [1.8.0] - 2023-04-10 + ### Changed - [Improve documentation regard `sql:Column` annotation](https://github.com/ballerina-platform/ballerina-standard-library/issues/4134) - [Handle null error messages from underlying drivers](https://github.com/ballerina-platform/ballerina-standard-library/issues/4200) From 2776ef05806ee7d4c97e91c455d6a353c04d3015 Mon Sep 17 00:00:00 2001 From: niveathika Date: Sat, 14 Oct 2023 10:19:01 +0530 Subject: [PATCH 03/10] Revert "Merge pull request #411 from niveathika/support-backtick" This reverts commit b9cf5c006ca602d41c9a3f8dfdfa860e17891bf3, reversing changes made to 49d0d487a78bf1f9acc4d48256ffda54461d5588. (cherry picked from commit 0854523871e0badce4c1722366d6e7a20d9f9dae) --- build-config/spotbugs-exclude.xml | 9 ----- changelog.md | 5 +++ .../io/ballerina/stdlib/sql/Constants.java | 1 - .../stdlib/sql/ParameterizedQuery.java | 39 ------------------- .../stdlib/sql/nativeimpl/CallProcessor.java | 21 +++++----- .../sql/nativeimpl/ExecuteProcessor.java | 22 +++++------ .../stdlib/sql/nativeimpl/QueryProcessor.java | 14 +++---- .../AbstractStatementParameterProcessor.java | 9 +++-- .../io/ballerina/stdlib/sql/utils/Utils.java | 23 ++++------- .../io/ballerina/stdlib/sql/TestUtils.java | 2 +- .../ballerina/stdlib/sql/utils/UtilsTest.java | 25 ------------ 11 files changed, 46 insertions(+), 124 deletions(-) delete mode 100644 native/src/main/java/io/ballerina/stdlib/sql/ParameterizedQuery.java diff --git a/build-config/spotbugs-exclude.xml b/build-config/spotbugs-exclude.xml index 9462f0a99..9e424c126 100644 --- a/build-config/spotbugs-exclude.xml +++ b/build-config/spotbugs-exclude.xml @@ -39,15 +39,6 @@ - - - - - - - - - diff --git a/changelog.md b/changelog.md index 58c29783d..6d4363d34 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - [Support retrieval of enum types](https://github.com/ballerina-platform/ballerina-standard-library/issues/4588) +## [1.9.1] + +### Changed +- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) + ## [1.9.0] - 2023-06-01 ### Changed diff --git a/native/src/main/java/io/ballerina/stdlib/sql/Constants.java b/native/src/main/java/io/ballerina/stdlib/sql/Constants.java index eb98c99ce..92dfeaf79 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/Constants.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/Constants.java @@ -77,7 +77,6 @@ private Constants() { public static final String PASSWORD = "password"; public static final String ANNON_RECORD_TYPE_NAME = "record {"; - public static final String BACKTICK = "`"; public static final String DEFAULT_STREAM_CONSTRAINT_NAME = "$stream$anon$constraint$"; public static final String INHERENT_TYPE_VIOLATION = "{ballerina/lang.map}InherentTypeViolation"; /** diff --git a/native/src/main/java/io/ballerina/stdlib/sql/ParameterizedQuery.java b/native/src/main/java/io/ballerina/stdlib/sql/ParameterizedQuery.java deleted file mode 100644 index eaddbd39c..000000000 --- a/native/src/main/java/io/ballerina/stdlib/sql/ParameterizedQuery.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.stdlib.sql; - -/** - * Processed Details from sql:ParameterizedQuery. - */ -public class ParameterizedQuery { - private final String sqlQuery; - private final Object[] insertions; - - public ParameterizedQuery(String sqlQuery, Object[] insertions) { - this.sqlQuery = sqlQuery; - this.insertions = insertions; - } - - public String getSqlQuery() { - return sqlQuery; - } - - public Object[] getInsertions() { - return insertions; - } -} diff --git a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/CallProcessor.java b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/CallProcessor.java index 2df7b5d70..17d8d70ac 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/CallProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/CallProcessor.java @@ -32,7 +32,6 @@ import io.ballerina.runtime.api.values.BTypedesc; import io.ballerina.runtime.transactions.TransactionResourceManager; import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.datasource.SQLDatasource; import io.ballerina.stdlib.sql.exception.ApplicationError; import io.ballerina.stdlib.sql.parameterprocessor.AbstractResultParameterProcessor; @@ -62,6 +61,7 @@ import static io.ballerina.stdlib.sql.datasource.SQLWorkerThreadPool.SQL_EXECUTOR_SERVICE; import static io.ballerina.stdlib.sql.utils.Utils.getColumnDefinitions; import static io.ballerina.stdlib.sql.utils.Utils.getDefaultStreamConstraint; +import static io.ballerina.stdlib.sql.utils.Utils.getSqlQuery; import static io.ballerina.stdlib.sql.utils.Utils.updateProcedureCallExecutionResult; /** @@ -121,13 +121,12 @@ private static Object nativeCallExecutable(BObject client, BObject paramSQLStrin ResultSet resultSet; String sqlQuery = null; try { - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(paramSQLString); - sqlQuery = parameterizedQuery.getSqlQuery(); + sqlQuery = getSqlQuery(paramSQLString); connection = SQLDatasource.getConnection(isWithinTrxBlock, trxResourceManager, client, sqlDatasource); statement = connection.prepareCall(sqlQuery); HashMap outputParamTypes = new HashMap<>(); - setCallParameters(connection, statement, parameterizedQuery.getInsertions(), outputParamTypes, + setCallParameters(connection, statement, paramSQLString, outputParamTypes, statementParameterProcessor); boolean resultType = statement.execute(); @@ -159,7 +158,7 @@ private static Object nativeCallExecutable(BObject client, BObject paramSQLStrin updateProcedureCallExecutionResult(statement, procedureCallResult); } - populateOutParameters(statement, parameterizedQuery.getInsertions(), outputParamTypes, + populateOutParameters(statement, paramSQLString, outputParamTypes, resultParameterProcessor); procedureCallResult.addNativeData(STATEMENT_NATIVE_DATA_FIELD, statement); @@ -182,11 +181,12 @@ private static Object nativeCallExecutable(BObject client, BObject paramSQLStrin } private static void setCallParameters(Connection connection, CallableStatement statement, - Object[] insertions, HashMap outputParamTypes, + BObject paramString, HashMap outputParamTypes, AbstractStatementParameterProcessor statementParameterProcessor) throws SQLException, ApplicationError { - for (int i = 0; i < insertions.length; i++) { - Object object = insertions[i]; + BArray arrayValue = paramString.getArrayValue(Constants.ParameterizedQueryFields.INSERTIONS); + for (int i = 0; i < arrayValue.size(); i++) { + Object object = arrayValue.get(i); int index = i + 1; if (object instanceof BObject) { BObject objectValue = (BObject) object; @@ -225,19 +225,20 @@ private static void setCallParameters(Connection connection, CallableStatement s } } - private static void populateOutParameters(CallableStatement statement, Object[] insertions, + private static void populateOutParameters(CallableStatement statement, BObject paramSQLString, HashMap outputParamTypes, AbstractResultParameterProcessor resultParameterProcessor) throws SQLException, ApplicationError { if (outputParamTypes.size() == 0) { return; } + BArray arrayValue = paramSQLString.getArrayValue(Constants.ParameterizedQueryFields.INSERTIONS); for (Map.Entry entry : outputParamTypes.entrySet()) { int paramIndex = entry.getKey(); int sqlType = entry.getValue(); - BObject parameter = (BObject) insertions[paramIndex - 1]; + BObject parameter = (BObject) arrayValue.get(paramIndex - 1); parameter.addNativeData(Constants.ParameterObject.SQL_TYPE_NATIVE_DATA, sqlType); Object result; diff --git a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/ExecuteProcessor.java b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/ExecuteProcessor.java index 30ff43d2f..a09aacc67 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/ExecuteProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/ExecuteProcessor.java @@ -28,7 +28,6 @@ import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.transactions.TransactionResourceManager; import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.datasource.SQLDatasource; import io.ballerina.stdlib.sql.exception.ApplicationError; import io.ballerina.stdlib.sql.parameterprocessor.AbstractStatementParameterProcessor; @@ -52,6 +51,7 @@ import static io.ballerina.stdlib.sql.datasource.SQLWorkerThreadPool.SQL_EXECUTOR_SERVICE; import static io.ballerina.stdlib.sql.utils.Utils.closeResources; import static io.ballerina.stdlib.sql.utils.Utils.getGeneratedKeys; +import static io.ballerina.stdlib.sql.utils.Utils.getSqlQuery; /** @@ -104,8 +104,7 @@ private static Object nativeExecuteExecutable(BObject client, BObject paramSQLSt ResultSet resultSet = null; String sqlQuery = null; try { - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(paramSQLString); - sqlQuery = parameterizedQuery.getSqlQuery(); + sqlQuery = getSqlQuery(paramSQLString); connection = SQLDatasource.getConnection(isWithInTrxBlock, trxResourceManager, client, sqlDatasource); if (sqlDatasource.getExecuteGKFlag()) { @@ -114,7 +113,7 @@ private static Object nativeExecuteExecutable(BObject client, BObject paramSQLSt statement = connection.prepareStatement(sqlQuery); } - statementParameterProcessor.setParams(connection, statement, parameterizedQuery.getInsertions()); + statementParameterProcessor.setParams(connection, statement, paramSQLString); int count = statement.executeUpdate(); Object lastInsertedId = null; @@ -184,19 +183,20 @@ private static Object nativeBatchExecuteExecutable(BObject client, BArray paramS Connection connection = null; PreparedStatement statement = null; String sqlQuery = null; - List parameters = new ArrayList<>(); + List parameters = new ArrayList<>(); List> executionResults = new ArrayList<>(); boolean processResultSet = false; int batchSize = 1000; try { Object[] paramSQLObjects = paramSQLStrings.getValues(); - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(((BObject) paramSQLObjects[0])); - sqlQuery = parameterizedQuery.getSqlQuery(); - parameters.add(parameterizedQuery.getInsertions()); + BObject parameterizedQuery = (BObject) paramSQLObjects[0]; + sqlQuery = getSqlQuery(parameterizedQuery); + parameters.add(parameterizedQuery); for (int paramIndex = 1; paramIndex < paramSQLStrings.size(); paramIndex++) { - parameterizedQuery = Utils.getParameterizedSQLQuery(((BObject) paramSQLObjects[paramIndex])); - if (sqlQuery.equals(parameterizedQuery.getSqlQuery())) { - parameters.add(parameterizedQuery.getInsertions()); + parameterizedQuery = (BObject) paramSQLObjects[paramIndex]; + String paramSQLQuery = getSqlQuery(parameterizedQuery); + if (sqlQuery.equals(paramSQLQuery)) { + parameters.add(parameterizedQuery); } else { return ErrorGenerator.getSQLApplicationError("Batch Execute cannot contain different SQL " + "commands. These has to be executed in different function calls"); diff --git a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/QueryProcessor.java b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/QueryProcessor.java index 4f31e0d67..b36621956 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/QueryProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/nativeimpl/QueryProcessor.java @@ -36,7 +36,6 @@ import io.ballerina.runtime.api.values.BTypedesc; import io.ballerina.runtime.transactions.TransactionResourceManager; import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.datasource.SQLDatasource; import io.ballerina.stdlib.sql.exception.ApplicationError; import io.ballerina.stdlib.sql.exception.DataError; @@ -115,11 +114,10 @@ private static BStream nativeQueryExecutable( ResultSet resultSet = null; String sqlQuery = null; try { - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(paramSQLString); - sqlQuery = parameterizedQuery.getSqlQuery(); + sqlQuery = Utils.getSqlQuery(paramSQLString); connection = SQLDatasource.getConnection(isWithInTrxBlock, trxResourceManager, client, sqlDatasource); statement = connection.prepareStatement(sqlQuery); - statementParameterProcessor.setParams(connection, statement, parameterizedQuery.getInsertions()); + statementParameterProcessor.setParams(connection, statement, paramSQLString); resultSet = statement.executeQuery(); RecordType streamConstraint = (RecordType) TypeUtils.getReferredType( ((BTypedesc) recordType).getDescribingType()); @@ -172,7 +170,8 @@ public static Object nativeQueryRow(Environment env, BObject client, BObject par } private static Object nativeQueryRowExecutable( - BObject client, BObject paramSQLString, BTypedesc ballerinaType, + BObject client, BObject paramSQLString, + BTypedesc ballerinaType, AbstractStatementParameterProcessor statementParameterProcessor, AbstractResultParameterProcessor resultParameterProcessor, boolean isWithInTrxBlock, TransactionResourceManager trxResourceManager) { @@ -189,11 +188,10 @@ private static Object nativeQueryRowExecutable( ResultSet resultSet = null; String sqlQuery = null; try { - ParameterizedQuery parameterizedQuery = Utils.getParameterizedSQLQuery(paramSQLString); - sqlQuery = parameterizedQuery.getSqlQuery(); + sqlQuery = Utils.getSqlQuery(paramSQLString); connection = SQLDatasource.getConnection(isWithInTrxBlock, trxResourceManager, client, sqlDatasource); statement = connection.prepareStatement(sqlQuery); - statementParameterProcessor.setParams(connection, statement, parameterizedQuery.getInsertions()); + statementParameterProcessor.setParams(connection, statement, paramSQLString); resultSet = statement.executeQuery(); if (!resultSet.next()) { return ErrorGenerator.getNoRowsError("Query did not retrieve any rows."); diff --git a/native/src/main/java/io/ballerina/stdlib/sql/parameterprocessor/AbstractStatementParameterProcessor.java b/native/src/main/java/io/ballerina/stdlib/sql/parameterprocessor/AbstractStatementParameterProcessor.java index 150d7f30e..260aedeab 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/parameterprocessor/AbstractStatementParameterProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/parameterprocessor/AbstractStatementParameterProcessor.java @@ -197,10 +197,11 @@ protected abstract void setXml(Connection connection, PreparedStatement prepared protected abstract int setCustomBOpenRecord(Connection connection, PreparedStatement preparedStatement, int index, Object value, boolean returnType) throws DataError, SQLException; - public void setParams(Connection connection, PreparedStatement preparedStatement, - Object[] insertions) throws DataError, SQLException { - for (int i = 0; i < insertions.length; i++) { - Object object = insertions[i]; + public void setParams(Connection connection, PreparedStatement preparedStatement, BObject paramString) + throws DataError, SQLException { + BArray arrayValue = paramString.getArrayValue(Constants.ParameterizedQueryFields.INSERTIONS); + for (int i = 0; i < arrayValue.size(); i++) { + Object object = arrayValue.get(i); int index = i + 1; setSQLValueParam(connection, preparedStatement, index, object, false); } diff --git a/native/src/main/java/io/ballerina/stdlib/sql/utils/Utils.java b/native/src/main/java/io/ballerina/stdlib/sql/utils/Utils.java index 0150773b9..c7ba4d4de 100644 --- a/native/src/main/java/io/ballerina/stdlib/sql/utils/Utils.java +++ b/native/src/main/java/io/ballerina/stdlib/sql/utils/Utils.java @@ -41,7 +41,6 @@ import io.ballerina.runtime.api.values.BValue; import io.ballerina.runtime.transactions.TransactionResourceManager; import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.exception.ApplicationError; import io.ballerina.stdlib.sql.exception.ConversionError; import io.ballerina.stdlib.sql.exception.DataError; @@ -87,7 +86,6 @@ import static io.ballerina.stdlib.sql.Constants.AFFECTED_ROW_COUNT_FIELD; import static io.ballerina.stdlib.sql.Constants.ANNON_RECORD_TYPE_NAME; import static io.ballerina.stdlib.sql.Constants.ANN_COLUMN_NAME_FIELD; -import static io.ballerina.stdlib.sql.Constants.BACKTICK; import static io.ballerina.stdlib.sql.Constants.COLUMN_ANN_NAME; import static io.ballerina.stdlib.sql.Constants.DEFAULT_STREAM_CONSTRAINT_NAME; import static io.ballerina.stdlib.sql.Constants.EXECUTION_RESULT_FIELD; @@ -158,23 +156,16 @@ public static void closeResources(boolean isWithinTrxBlock, ResultSet resultSet, } } - public static ParameterizedQuery getParameterizedSQLQuery(BObject paramString) { + public static String getSqlQuery(BObject paramString) { + BArray stringsArray = paramString.getArrayValue(Constants.ParameterizedQueryFields.STRINGS); StringBuilder sqlQuery = new StringBuilder(); - List insertions = new ArrayList<>(); - - BArray bStringsArray = paramString.getArrayValue(Constants.ParameterizedQueryFields.STRINGS); - BArray bInsertions = paramString.getArrayValue(Constants.ParameterizedQueryFields.INSERTIONS); - for (int i = 0; i < bInsertions.size(); i++) { - if (bInsertions.get(i) instanceof BString && bInsertions.getBString(i).getValue().equals(BACKTICK)) { - sqlQuery.append(bStringsArray.getBString(i).getValue()).append(BACKTICK); - } else { - insertions.add(bInsertions.get(i)); - sqlQuery.append(bStringsArray.getBString(i).getValue()).append(" ? "); + for (int i = 0; i < stringsArray.size(); i++) { + if (i > 0) { + sqlQuery.append(" ? "); } + sqlQuery.append(stringsArray.get(i).toString()); } - sqlQuery.append(bStringsArray.getBString(bInsertions.size())); - - return new ParameterizedQuery(sqlQuery.toString(), insertions.toArray()); + return sqlQuery.toString(); } public static DataError throwInvalidParameterError(Object value, String sqlType) { diff --git a/native/src/test/java/io/ballerina/stdlib/sql/TestUtils.java b/native/src/test/java/io/ballerina/stdlib/sql/TestUtils.java index 1eedca478..4ed8ded2b 100644 --- a/native/src/test/java/io/ballerina/stdlib/sql/TestUtils.java +++ b/native/src/test/java/io/ballerina/stdlib/sql/TestUtils.java @@ -145,7 +145,7 @@ public BObject getObjectValue(BString bString) { @Override public BArray getArrayValue(BString bString) { - return ((BArray) nativeData.get(bString.getValue())); + return null; } @Override diff --git a/native/src/test/java/io/ballerina/stdlib/sql/utils/UtilsTest.java b/native/src/test/java/io/ballerina/stdlib/sql/utils/UtilsTest.java index a8d3cfec7..dae405b39 100644 --- a/native/src/test/java/io/ballerina/stdlib/sql/utils/UtilsTest.java +++ b/native/src/test/java/io/ballerina/stdlib/sql/utils/UtilsTest.java @@ -18,20 +18,14 @@ package io.ballerina.stdlib.sql.utils; -import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.StructureType; import io.ballerina.runtime.api.utils.TypeUtils; -import io.ballerina.runtime.api.values.BObject; -import io.ballerina.runtime.api.values.BString; -import io.ballerina.stdlib.sql.Constants; -import io.ballerina.stdlib.sql.ParameterizedQuery; import io.ballerina.stdlib.sql.TestUtils; import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; -import static io.ballerina.runtime.api.utils.StringUtils.fromString; import static org.testng.Assert.assertEquals; /** @@ -62,23 +56,4 @@ void getDefaultRecordTypeTest() { StructureType structureType = Utils.getDefaultRecordType(list); assertEquals(structureType.getFlags(), 0); } - - @Test - void backTickEscapeTest() { - // HSQLDB does not support backtick quotes - BObject bParameterizedQuery = TestUtils.getMockObject("parameterizedQuery"); - - BString[] bStrings = {fromString("x"), fromString("y"), fromString("z"), fromString("")}; - - BString[] insertions = {fromString("`"), fromString("abc"), fromString("`") }; - - - bParameterizedQuery.addNativeData(Constants.ParameterizedQueryFields.STRINGS.getValue(), - ValueCreator.createArrayValue(bStrings)); - bParameterizedQuery.addNativeData(Constants.ParameterizedQueryFields.INSERTIONS.getValue(), - ValueCreator.createArrayValue(insertions)); - - ParameterizedQuery parameterizedSQLQuery = Utils.getParameterizedSQLQuery(bParameterizedQuery); - assertEquals(parameterizedSQLQuery.getSqlQuery(), "x`y ? z`"); - } } From 9fe0f22bdff084a973814b6cedd5ebc23f5bfdc9 Mon Sep 17 00:00:00 2001 From: niveathika Date: Sun, 15 Oct 2023 15:17:21 +0530 Subject: [PATCH 04/10] Sync changelog (cherry picked from commit 3419fe81174bdfb1dd61b9957f713ab35c2fdb54) --- changelog.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 6d4363d34..56217898e 100644 --- a/changelog.md +++ b/changelog.md @@ -9,15 +9,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed -- [Support retrieval of enum types](https://github.com/ballerina-platform/ballerina-standard-library/issues/4588) +- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) + +## [1.11.0] - 2023-09-18 + +### Added +- Support for Java17 + +## [1.10.0] - 2023-06-30 -## [1.9.1] +### Added +- [Support retrieval of enum types](https://github.com/ballerina-platform/ballerina-standard-library/issues/4588) ### Changed -- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) +- [Fix failure for unsupported time type](https://github.com/ballerina-platform/ballerina-standard-library/issues/4531) ## [1.9.0] - 2023-06-01 +### Changed +- Add GraalVM support + +## [1.8.0] - 2023-04-10 + ### Changed - [Improve documentation regard `sql:Column` annotation](https://github.com/ballerina-platform/ballerina-standard-library/issues/4134) - [Handle null error messages from underlying drivers](https://github.com/ballerina-platform/ballerina-standard-library/issues/4200) From 15e115afa01a1641cfbcda2ff96ef3d9ae581895 Mon Sep 17 00:00:00 2001 From: niveathika Date: Sun, 15 Oct 2023 16:25:10 +0530 Subject: [PATCH 05/10] Add branch to PR check --- .github/workflows/pull-request.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 5418f2cee..439298314 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -5,6 +5,7 @@ on: branches: - master - 2201.[0-9]+.x + - v1.11.x jobs: ubuntu-build: From 76f313f75d2544aab90260b7fa5f446161e520f5 Mon Sep 17 00:00:00 2001 From: ballerina-bot Date: Mon, 16 Oct 2023 04:39:02 +0000 Subject: [PATCH 06/10] [Automated] Update native jar versions in toml files --- ballerina/Ballerina.toml | 8 ++++---- ballerina/CompilerPlugin.toml | 2 +- ballerina/Dependencies.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index f823c2c66..ce6d5ff9c 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "sql" -version = "1.11.0" +version = "1.11.1" authors = ["Ballerina"] keywords = ["database", "client", "network", "SQL", "RDBMS"] repository = "https://github.com/ballerina-platform/module-ballerina-sql" @@ -15,11 +15,11 @@ graalvmCompatible = true [[platform.java17.dependency]] groupId = "io.ballerina.stdlib" artifactId = "sql-native" -version = "1.11.0" -path = "../native/build/libs/sql-native-1.11.0.jar" +version = "1.11.1" +path = "../native/build/libs/sql-native-1.11.1-SNAPSHOT.jar" [[platform.java17.dependency]] -path = "../test-utils/build/libs/sql-test-utils-1.11.0.jar" +path = "../test-utils/build/libs/sql-test-utils-1.11.1-SNAPSHOT.jar" scope = "testOnly" [[platform.java17.dependency]] diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 2dfd28cbe..3f494b01e 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "sql-compiler-plugin" class = "io.ballerina.stdlib.sql.compiler.SQLCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/sql-compiler-plugin-1.11.0.jar" +path = "../compiler-plugin/build/libs/sql-compiler-plugin-1.11.1-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index d47a2a705..136d61c78 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -300,7 +300,7 @@ dependencies = [ [[package]] org = "ballerina" name = "sql" -version = "1.11.0" +version = "1.11.1" dependencies = [ {org = "ballerina", name = "file"}, {org = "ballerina", name = "io"}, From f1d1296f62d8e1178f524bc0b8ddf28a47ba779c Mon Sep 17 00:00:00 2001 From: ballerina-bot Date: Mon, 16 Oct 2023 04:49:49 +0000 Subject: [PATCH 07/10] [Automated] Update native jar versions in toml files --- ballerina/Ballerina.toml | 4 ++-- ballerina/CompilerPlugin.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index ce6d5ff9c..6aa1f0594 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -16,10 +16,10 @@ graalvmCompatible = true groupId = "io.ballerina.stdlib" artifactId = "sql-native" version = "1.11.1" -path = "../native/build/libs/sql-native-1.11.1-SNAPSHOT.jar" +path = "../native/build/libs/sql-native-1.11.1.jar" [[platform.java17.dependency]] -path = "../test-utils/build/libs/sql-test-utils-1.11.1-SNAPSHOT.jar" +path = "../test-utils/build/libs/sql-test-utils-1.11.1.jar" scope = "testOnly" [[platform.java17.dependency]] diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 3f494b01e..d27b59f70 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "sql-compiler-plugin" class = "io.ballerina.stdlib.sql.compiler.SQLCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/sql-compiler-plugin-1.11.1-SNAPSHOT.jar" +path = "../compiler-plugin/build/libs/sql-compiler-plugin-1.11.1.jar" From 1910f278dd5816353423eabfccc1906d54fddac7 Mon Sep 17 00:00:00 2001 From: ballerina-bot Date: Mon, 16 Oct 2023 04:50:10 +0000 Subject: [PATCH 08/10] [Gradle Release Plugin] - pre tag commit: 'v1.11.1'. --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7dba82666..119c0ac5a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=io.ballerina.stdlib -version=1.11.1-SNAPSHOT +version=1.11.1 puppycrawlCheckstyleVersion=10.12.1 hikkariLibVersion=3.3.1 From 6116482b92492d5e72cfdba4dd090702e140bea1 Mon Sep 17 00:00:00 2001 From: ballerina-bot Date: Mon, 16 Oct 2023 04:50:12 +0000 Subject: [PATCH 09/10] [Gradle Release Plugin] - new version commit: 'v1.11.2-SNAPSHOT'. --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 119c0ac5a..79e5ebee1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=io.ballerina.stdlib -version=1.11.1 +version=1.11.2-SNAPSHOT puppycrawlCheckstyleVersion=10.12.1 hikkariLibVersion=3.3.1 From 375e994b7565fb0b822e7e0af8b39d84268d248a Mon Sep 17 00:00:00 2001 From: Niveathika Date: Mon, 16 Oct 2023 10:23:31 +0530 Subject: [PATCH 10/10] Sync changelog --- changelog.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/changelog.md b/changelog.md index 56217898e..aaa2eb2c2 100644 --- a/changelog.md +++ b/changelog.md @@ -11,11 +11,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) +## [1.11.1] - 2023-10-16 + +### Changed +- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) + ## [1.11.0] - 2023-09-18 ### Added - Support for Java17 +## [1.10.1] - 2023-10-16 + +### Changed +- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) + ## [1.10.0] - 2023-06-30 ### Added @@ -24,11 +34,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - [Fix failure for unsupported time type](https://github.com/ballerina-platform/ballerina-standard-library/issues/4531) +## [1.9.1] - 2023-10-16 + +### Changed +- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) + ## [1.9.0] - 2023-06-01 ### Changed - Add GraalVM support +## [1.8.1] - 2023-10-16 + +### Changed +- [Revert Accept escaped backtick as insertions in parameterised query](https://github.com/ballerina-platform/ballerina-standard-library/issues/2056) + ## [1.8.0] - 2023-04-10 ### Changed