From 4e4422172452bd2c53601104637094b5f7cc3dc8 Mon Sep 17 00:00:00 2001 From: aashikam Date: Tue, 13 Feb 2024 14:05:49 +0530 Subject: [PATCH 1/3] Remove un-used code This is copied from JDBC connector --- .../java/io/ballerina/lib/aws/redshift/Constants.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/native/src/main/java/io/ballerina/lib/aws/redshift/Constants.java b/native/src/main/java/io/ballerina/lib/aws/redshift/Constants.java index 60f57fe..1ab883d 100644 --- a/native/src/main/java/io/ballerina/lib/aws/redshift/Constants.java +++ b/native/src/main/java/io/ballerina/lib/aws/redshift/Constants.java @@ -51,13 +51,4 @@ public static final class SSL { } public static final String CONNECT_TIMEOUT = ".*(connect).*(timeout).*"; public static final String POOL_CONNECTION_TIMEOUT = "ConnectionTimeout"; - - /** - * Constants for Request Generated Keys field. - */ - public static final class RequestGeneratedKeysValues { - public static final String ALL = "ALL"; - public static final String EXECUTE = "EXECUTE"; - public static final String BATCH_EXECUTE = "BATCH_EXECUTE"; - } } From fd9bff35e8e919aaef6bd85f5dd9a634741a3188 Mon Sep 17 00:00:00 2001 From: aashikam Date: Tue, 13 Feb 2024 14:40:13 +0530 Subject: [PATCH 2/3] [Automated] Update the toml files --- ballerina/Ballerina.toml | 6 +++--- ballerina/Dependencies.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index fbedae2..da1d97d 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerinax" name = "aws.redshift" -version = "1.0.1" +version = "1.0.2" authors = ["Ballerina"] keywords = ["Data Warehouse", "Columnar Storage", "Cost/Paid", "vendor/aws"] repository = "https://github.com/ballerina-platform/module-ballerinax-aws.redshift" @@ -15,8 +15,8 @@ graalvmCompatible = true [[platform.java11.dependency]] groupId = "io.ballerina.stdlib" artifactId = "aws.redshift-native" -version = "1.0.1" -path = "../native/build/libs/aws.redshift-native-1.0.1.jar" +version = "1.0.2-SNAPSHOT" +path = "../native/build/libs/aws.redshift-native-1.0.2-SNAPSHOT.jar" [[platform.java11.dependency]] groupId = "io.ballerina.stdlib" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 6492469..877f37e 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -108,7 +108,7 @@ dependencies = [ [[package]] org = "ballerinax" name = "aws.redshift" -version = "1.0.1" +version = "1.0.2" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "log"}, From 3c6ea8a941617def6e1b899d0331c257fc3a4c7c Mon Sep 17 00:00:00 2001 From: aashikam Date: Tue, 13 Feb 2024 14:51:32 +0530 Subject: [PATCH 3/3] Add tests for query row --- ballerina/tests/query-basic-tests.bal | 29 +++++++++++++++++++++++++++ ballerina/tests/setup-tests.bal | 15 ++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 ballerina/tests/query-basic-tests.bal diff --git a/ballerina/tests/query-basic-tests.bal b/ballerina/tests/query-basic-tests.bal new file mode 100644 index 0000000..5910531 --- /dev/null +++ b/ballerina/tests/query-basic-tests.bal @@ -0,0 +1,29 @@ +// Copyright (c) 2024 WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +// +// WSO2 LLC. 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. + +import ballerina/sql; +import ballerina/test; + +@test:Config { + groups: ["query-row"] +} +function TestConnectionClose() returns error? { + sql:ParameterizedQuery sqlQuery = `SELECT username FROM users WHERE user_id = 2;`; + Client dbClient = check new (jdbcUrl, user, password); + string stringVal = check dbClient->queryRow(sqlQuery); + test:assertEquals(stringVal, "JaneSmith"); + check dbClient.close(); +} diff --git a/ballerina/tests/setup-tests.bal b/ballerina/tests/setup-tests.bal index 4571202..c7b0fe9 100644 --- a/ballerina/tests/setup-tests.bal +++ b/ballerina/tests/setup-tests.bal @@ -54,5 +54,20 @@ function beforeFunction() returns error? { END; $$; `); + _ = check dbClient->execute(` + CREATE TABLE IF NOT EXISTS users ( + user_id INT, + username VARCHAR(255), + email VARCHAR(255), + age INT + ); + `); + + _ = check dbClient->execute(` + INSERT INTO users (user_id, username, email, age) VALUES + (1, 'JohnDoe', 'john.doe@example.com', 25), + (2, 'JaneSmith', 'jane.smith@example.com', 30), + (3, 'BobJohnson', 'bob.johnson@example.com', 22); + `); check dbClient.close(); }