From d68337469f43207dfa41633480f5bbe2ead2f8f2 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Sat, 25 May 2024 20:22:27 +0530 Subject: [PATCH 1/9] Add testcases for failing bulk insert usecase --- ballerina/tests/init-tests.bal | 46 +++++++++++++++++++ ballerina/tests/mssql-all-types-tests.bal | 43 +++++++++++++---- ballerina/tests/mysql-all-types-tests.bal | 43 +++++++++++++---- .../tests/postgresql-all-types-tests.bal | 43 +++++++++++++---- 4 files changed, 148 insertions(+), 27 deletions(-) diff --git a/ballerina/tests/init-tests.bal b/ballerina/tests/init-tests.bal index 5489326..56d5834 100644 --- a/ballerina/tests/init-tests.bal +++ b/ballerina/tests/init-tests.bal @@ -427,6 +427,52 @@ AllTypes allTypes3Expected = { enumTypeOptional: allTypes3.enumTypeOptional }; +AllTypes allTypes4 = { + id: 4, + booleanType: true, + intType: 35, + floatType: 63.0, + decimalType: 233.44, + stringType: "test2", + byteArrayType: base16 `55 EE 66 AF 77 AB`, + dateType: {year: 1996, month: 11, day: 3}, + timeOfDayType: {hour: 17, minute: 32, second: 34}, + civilType: {year: 1999, month: 11, day: 3, hour: 12, minute: 32, second: 34}, + booleanTypeOptional: true, + intTypeOptional: 35, + floatTypeOptional: 63.0, + decimalTypeOptional: 233.44, + stringTypeOptional: "test2", + dateTypeOptional: {year: 1996, month: 11, day: 3}, + timeOfDayTypeOptional: {hour: 17, minute: 32, second: 34}, + civilTypeOptional: {year: 1999, month: 11, day: 3, hour: 12, minute: 32, second: 34}, + enumType: "TYPE_1", + enumTypeOptional: "TYPE_3" +}; + +AllTypes allTypes4Expected = { + id: allTypes4.id, + booleanType: allTypes4.booleanType, + intType: allTypes4.intType, + floatType: allTypes4.floatType, + decimalType: allTypes4.decimalType, + stringType: allTypes4.stringType, + byteArrayType: allTypes4.byteArrayType, + dateType: allTypes4.dateType, + timeOfDayType: allTypes4.timeOfDayType, + civilType: allTypes4.civilType, + booleanTypeOptional: allTypes4.booleanTypeOptional, + intTypeOptional: allTypes4.intTypeOptional, + floatTypeOptional: allTypes4.floatTypeOptional, + decimalTypeOptional: allTypes4.decimalTypeOptional, + stringTypeOptional: allTypes4.stringTypeOptional, + dateTypeOptional: allTypes4.dateTypeOptional, + timeOfDayTypeOptional: allTypes4.timeOfDayTypeOptional, + civilTypeOptional: allTypes4.civilTypeOptional, + enumType: allTypes4.enumType, + enumTypeOptional: allTypes4.enumTypeOptional +}; + AllTypes allTypes1Updated = { id: 1, booleanType: true, diff --git a/ballerina/tests/mssql-all-types-tests.bal b/ballerina/tests/mssql-all-types-tests.bal index 03cf186..9b91c1b 100644 --- a/ballerina/tests/mssql-all-types-tests.bal +++ b/ballerina/tests/mssql-all-types-tests.bal @@ -38,21 +38,24 @@ function mssqlAllTypesCreateTest() returns error? { @test:Config { groups: ["all-types", "mssql"] } -function mssqlAllTypesCreateOptionalTest() returns error? { +function mssqlAllTypesCreateMixedTest() returns error? { MSSQLTestEntitiesClient testEntitiesClient = check new (); - int[] ids = check testEntitiesClient->/alltypes.post([allTypes3]); - test:assertEquals(ids, [allTypes3.id]); + int[] ids = check testEntitiesClient->/alltypes.post([allTypes3, allTypes4]); + test:assertEquals(ids, [allTypes3.id, allTypes4.id]); AllTypes allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes3.id].get(); test:assertEquals(allTypesRetrieved, allTypes3Expected); + allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes4.id].get(); + test:assertEquals(allTypesRetrieved, allTypes4Expected); + check testEntitiesClient.close(); } @test:Config { groups: ["all-types", "mssql"], - dependsOn: [mssqlAllTypesCreateTest, mssqlAllTypesCreateOptionalTest] + dependsOn: [mssqlAllTypesCreateTest, mssqlAllTypesCreateMixedTest] } function mssqlAllTypesReadTest() returns error? { MSSQLTestEntitiesClient testEntitiesClient = check new (); @@ -61,13 +64,13 @@ function mssqlAllTypesReadTest() returns error? { AllTypes[] allTypes = check from AllTypes allTypesRecord in allTypesStream select allTypesRecord; - test:assertEquals(allTypes, [allTypes1Expected, allTypes2Expected, allTypes3Expected]); + test:assertEquals(allTypes, [allTypes1Expected, allTypes2Expected, allTypes3Expected, allTypes4Expected]); check testEntitiesClient.close(); } @test:Config { groups: ["all-types", "mssql", "dependent"], - dependsOn: [mssqlAllTypesCreateTest, mssqlAllTypesCreateOptionalTest] + dependsOn: [mssqlAllTypesCreateTest, mssqlAllTypesCreateMixedTest] } function mssqlAllTypesReadDependentTest() returns error? { MSSQLTestEntitiesClient testEntitiesClient = check new (); @@ -133,6 +136,25 @@ function mssqlAllTypesReadDependentTest() returns error? { dateTypeOptional: allTypes3Expected.dateTypeOptional, timeOfDayTypeOptional: allTypes3Expected.timeOfDayTypeOptional, civilTypeOptional: allTypes3Expected.civilTypeOptional + }, + { + booleanType: allTypes4Expected.booleanType, + intType: allTypes4Expected.intType, + floatType: allTypes4Expected.floatType, + decimalType: allTypes4Expected.decimalType, + stringType: allTypes4Expected.stringType, + byteArrayType: allTypes4Expected.byteArrayType, + dateType: allTypes4Expected.dateType, + timeOfDayType: allTypes4Expected.timeOfDayType, + civilType: allTypes4Expected.civilType, + booleanTypeOptional: allTypes4Expected.booleanTypeOptional, + intTypeOptional: allTypes4Expected.intTypeOptional, + floatTypeOptional: allTypes4Expected.floatTypeOptional, + decimalTypeOptional: allTypes4Expected.decimalTypeOptional, + stringTypeOptional: allTypes4Expected.stringTypeOptional, + dateTypeOptional: allTypes4Expected.dateTypeOptional, + timeOfDayTypeOptional: allTypes4Expected.timeOfDayTypeOptional, + civilTypeOptional: allTypes4Expected.civilTypeOptional } ]); check testEntitiesClient.close(); @@ -140,7 +162,7 @@ function mssqlAllTypesReadDependentTest() returns error? { @test:Config { groups: ["all-types", "mssql"], - dependsOn: [mssqlAllTypesCreateTest, mssqlAllTypesCreateOptionalTest] + dependsOn: [mssqlAllTypesCreateTest, mssqlAllTypesCreateMixedTest] } function mssqlAllTypesReadOneTest() returns error? { MSSQLTestEntitiesClient testEntitiesClient = check new (); @@ -154,6 +176,9 @@ function mssqlAllTypesReadOneTest() returns error? { allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes3.id].get(); test:assertEquals(allTypesRetrieved, allTypes3Expected); + allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes4.id].get(); + test:assertEquals(allTypesRetrieved, allTypes4Expected); + check testEntitiesClient.close(); } @@ -163,9 +188,9 @@ function mssqlAllTypesReadOneTest() returns error? { function mssqlAllTypesReadOneTestNegative() returns error? { MSSQLTestEntitiesClient testEntitiesClient = check new (); - AllTypes|persist:Error allTypesRetrieved = testEntitiesClient->/alltypes/[4].get(); + AllTypes|persist:Error allTypesRetrieved = testEntitiesClient->/alltypes/[5].get(); if allTypesRetrieved is persist:NotFoundError { - test:assertEquals(allTypesRetrieved.message(), "A record with the key '4' does not exist for the entity 'AllTypes'."); + test:assertEquals(allTypesRetrieved.message(), "A record with the key '5' does not exist for the entity 'AllTypes'."); } else { test:assertFail("persist:NotFoundError expected."); diff --git a/ballerina/tests/mysql-all-types-tests.bal b/ballerina/tests/mysql-all-types-tests.bal index 6504d0c..9226831 100644 --- a/ballerina/tests/mysql-all-types-tests.bal +++ b/ballerina/tests/mysql-all-types-tests.bal @@ -38,21 +38,24 @@ function mysqlAllTypesCreateTest() returns error? { @test:Config { groups: ["all-types", "mysql"] } -function mysqlAllTypesCreateOptionalTest() returns error? { +function mysqlAllTypesCreateMixedTest() returns error? { MySQLTestEntitiesClient testEntitiesClient = check new (); - int[] ids = check testEntitiesClient->/alltypes.post([allTypes3]); - test:assertEquals(ids, [allTypes3.id]); + int[] ids = check testEntitiesClient->/alltypes.post([allTypes3, allTypes4]); + test:assertEquals(ids, [allTypes3.id, allTypes4.id]); AllTypes allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes3.id].get(); test:assertEquals(allTypesRetrieved, allTypes3Expected); + allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes4.id].get(); + test:assertEquals(allTypesRetrieved, allTypes4Expected); + check testEntitiesClient.close(); } @test:Config { groups: ["all-types", "mysql"], - dependsOn: [mysqlAllTypesCreateTest, mysqlAllTypesCreateOptionalTest] + dependsOn: [mysqlAllTypesCreateTest, mysqlAllTypesCreateMixedTest] } function mysqlAllTypesReadTest() returns error? { MySQLTestEntitiesClient testEntitiesClient = check new (); @@ -61,13 +64,13 @@ function mysqlAllTypesReadTest() returns error? { AllTypes[] allTypes = check from AllTypes allTypesRecord in allTypesStream select allTypesRecord; - test:assertEquals(allTypes, [allTypes1Expected, allTypes2Expected, allTypes3Expected]); + test:assertEquals(allTypes, [allTypes1Expected, allTypes2Expected, allTypes3Expected, allTypes4Expected]); check testEntitiesClient.close(); } @test:Config { groups: ["all-types", "mysql", "dependent"], - dependsOn: [mysqlAllTypesCreateTest, mysqlAllTypesCreateOptionalTest] + dependsOn: [mysqlAllTypesCreateTest, mysqlAllTypesCreateMixedTest] } function mysqlAllTypesReadDependentTest() returns error? { MySQLTestEntitiesClient testEntitiesClient = check new (); @@ -133,6 +136,25 @@ function mysqlAllTypesReadDependentTest() returns error? { dateTypeOptional: allTypes3Expected.dateTypeOptional, timeOfDayTypeOptional: allTypes3Expected.timeOfDayTypeOptional, civilTypeOptional: allTypes3Expected.civilTypeOptional + }, + { + booleanType: allTypes4Expected.booleanType, + intType: allTypes4Expected.intType, + floatType: allTypes4Expected.floatType, + decimalType: allTypes4Expected.decimalType, + stringType: allTypes4Expected.stringType, + byteArrayType: allTypes4Expected.byteArrayType, + dateType: allTypes4Expected.dateType, + timeOfDayType: allTypes4Expected.timeOfDayType, + civilType: allTypes4Expected.civilType, + booleanTypeOptional: allTypes4Expected.booleanTypeOptional, + intTypeOptional: allTypes4Expected.intTypeOptional, + floatTypeOptional: allTypes4Expected.floatTypeOptional, + decimalTypeOptional: allTypes4Expected.decimalTypeOptional, + stringTypeOptional: allTypes4Expected.stringTypeOptional, + dateTypeOptional: allTypes4Expected.dateTypeOptional, + timeOfDayTypeOptional: allTypes4Expected.timeOfDayTypeOptional, + civilTypeOptional: allTypes4Expected.civilTypeOptional } ]); check testEntitiesClient.close(); @@ -140,7 +162,7 @@ function mysqlAllTypesReadDependentTest() returns error? { @test:Config { groups: ["all-types", "mysql"], - dependsOn: [mysqlAllTypesCreateTest, mysqlAllTypesCreateOptionalTest] + dependsOn: [mysqlAllTypesCreateTest, mysqlAllTypesCreateMixedTest] } function mysqlAllTypesReadOneTest() returns error? { MySQLTestEntitiesClient testEntitiesClient = check new (); @@ -154,6 +176,9 @@ function mysqlAllTypesReadOneTest() returns error? { allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes3.id].get(); test:assertEquals(allTypesRetrieved, allTypes3Expected); + allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes4.id].get(); + test:assertEquals(allTypesRetrieved, allTypes4Expected); + check testEntitiesClient.close(); } @@ -163,9 +188,9 @@ function mysqlAllTypesReadOneTest() returns error? { function mysqlAllTypesReadOneTestNegative() returns error? { MySQLTestEntitiesClient testEntitiesClient = check new (); - AllTypes|persist:Error allTypesRetrieved = testEntitiesClient->/alltypes/[4].get(); + AllTypes|persist:Error allTypesRetrieved = testEntitiesClient->/alltypes/[5].get(); if allTypesRetrieved is persist:NotFoundError { - test:assertEquals(allTypesRetrieved.message(), "A record with the key '4' does not exist for the entity 'AllTypes'."); + test:assertEquals(allTypesRetrieved.message(), "A record with the key '5' does not exist for the entity 'AllTypes'."); } else { test:assertFail("persist:NotFoundError expected."); diff --git a/ballerina/tests/postgresql-all-types-tests.bal b/ballerina/tests/postgresql-all-types-tests.bal index fe4fd24..af288fb 100644 --- a/ballerina/tests/postgresql-all-types-tests.bal +++ b/ballerina/tests/postgresql-all-types-tests.bal @@ -38,21 +38,24 @@ function postgresqlAllTypesCreateTest() returns error? { @test:Config { groups: ["all-types", "postgresql"] } -function postgresqlAllTypesCreateOptionalTest() returns error? { +function postgresqlAllTypesCreateMixedTest() returns error? { PostgreSQLTestEntitiesClient testEntitiesClient = check new (); - int[] ids = check testEntitiesClient->/alltypes.post([allTypes3]); - test:assertEquals(ids, [allTypes3.id]); + int[] ids = check testEntitiesClient->/alltypes.post([allTypes3, allTypes4]); + test:assertEquals(ids, [allTypes3.id, allTypes4.id]); AllTypes allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes3.id].get(); test:assertEquals(allTypesRetrieved, allTypes3Expected); + allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes4.id].get(); + test:assertEquals(allTypesRetrieved, allTypes4Expected); + check testEntitiesClient.close(); } @test:Config { groups: ["all-types", "postgresql"], - dependsOn: [postgresqlAllTypesCreateTest, postgresqlAllTypesCreateOptionalTest] + dependsOn: [postgresqlAllTypesCreateTest, postgresqlAllTypesCreateMixedTest] } function postgresqlAllTypesReadTest() returns error? { PostgreSQLTestEntitiesClient testEntitiesClient = check new (); @@ -61,13 +64,13 @@ function postgresqlAllTypesReadTest() returns error? { AllTypes[] allTypes = check from AllTypes allTypesRecord in allTypesStream select allTypesRecord; - test:assertEquals(allTypes, [allTypes3Expected, allTypes1Expected, allTypes2Expected]); + test:assertEquals(allTypes, [allTypes3Expected, allTypes1Expected, allTypes2Expected, allTypes4Expected]); check testEntitiesClient.close(); } @test:Config { groups: ["all-types", "postgresql", "dependent"], - dependsOn: [postgresqlAllTypesCreateTest, postgresqlAllTypesCreateOptionalTest] + dependsOn: [postgresqlAllTypesCreateTest, postgresqlAllTypesCreateMixedTest] } function postgresqlAllTypesReadDependentTest() returns error? { PostgreSQLTestEntitiesClient testEntitiesClient = check new (); @@ -133,6 +136,25 @@ function postgresqlAllTypesReadDependentTest() returns error? { dateTypeOptional: allTypes2Expected.dateTypeOptional, timeOfDayTypeOptional: allTypes2Expected.timeOfDayTypeOptional, civilTypeOptional: allTypes2Expected.civilTypeOptional + }, + { + booleanType: allTypes4Expected.booleanType, + intType: allTypes4Expected.intType, + floatType: allTypes4Expected.floatType, + decimalType: allTypes4Expected.decimalType, + stringType: allTypes4Expected.stringType, + byteArrayType: allTypes4Expected.byteArrayType, + dateType: allTypes4Expected.dateType, + timeOfDayType: allTypes4Expected.timeOfDayType, + civilType: allTypes4Expected.civilType, + booleanTypeOptional: allTypes4Expected.booleanTypeOptional, + intTypeOptional: allTypes4Expected.intTypeOptional, + floatTypeOptional: allTypes4Expected.floatTypeOptional, + decimalTypeOptional: allTypes4Expected.decimalTypeOptional, + stringTypeOptional: allTypes4Expected.stringTypeOptional, + dateTypeOptional: allTypes4Expected.dateTypeOptional, + timeOfDayTypeOptional: allTypes4Expected.timeOfDayTypeOptional, + civilTypeOptional: allTypes4Expected.civilTypeOptional } ]); check testEntitiesClient.close(); @@ -140,7 +162,7 @@ function postgresqlAllTypesReadDependentTest() returns error? { @test:Config { groups: ["all-types", "postgresql"], - dependsOn: [postgresqlAllTypesCreateTest, postgresqlAllTypesCreateOptionalTest] + dependsOn: [postgresqlAllTypesCreateTest, postgresqlAllTypesCreateMixedTest] } function postgresqlAllTypesReadOneTest() returns error? { PostgreSQLTestEntitiesClient testEntitiesClient = check new (); @@ -154,6 +176,9 @@ function postgresqlAllTypesReadOneTest() returns error? { allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes3.id].get(); test:assertEquals(allTypesRetrieved, allTypes3Expected); + allTypesRetrieved = check testEntitiesClient->/alltypes/[allTypes4.id].get(); + test:assertEquals(allTypesRetrieved, allTypes4Expected); + check testEntitiesClient.close(); } @@ -163,9 +188,9 @@ function postgresqlAllTypesReadOneTest() returns error? { function postgresqlAllTypesReadOneTestNegative() returns error? { PostgreSQLTestEntitiesClient testEntitiesClient = check new (); - AllTypes|persist:Error allTypesRetrieved = testEntitiesClient->/alltypes/[4].get(); + AllTypes|persist:Error allTypesRetrieved = testEntitiesClient->/alltypes/[5].get(); if allTypesRetrieved is persist:NotFoundError { - test:assertEquals(allTypesRetrieved.message(), "A record with the key '4' does not exist for the entity 'AllTypes'."); + test:assertEquals(allTypesRetrieved.message(), "A record with the key '5' does not exist for the entity 'AllTypes'."); } else { test:assertFail("persist:NotFoundError expected."); From e663a5b6ab9fb6e48efa41941dd9c78a872dd1e9 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Sat, 25 May 2024 20:30:10 +0530 Subject: [PATCH 2/9] Remove the special check for nil values --- ballerina/sql_client.bal | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ballerina/sql_client.bal b/ballerina/sql_client.bal index 8ab5940..9fc736c 100644 --- a/ballerina/sql_client.bal +++ b/ballerina/sql_client.bal @@ -254,12 +254,7 @@ public isolated client class SQLClient { if columnCount > 0 { params = sql:queryConcat(params, `,`); } - - if 'object[key] is () { - params = sql:queryConcat(params, `NULL`); - } else { - params = sql:queryConcat(params, `${'object[key]}`); - } + params = sql:queryConcat(params, `${'object[key]}`); columnCount = columnCount + 1; } params = sql:queryConcat(params, `)`); From 2a7c7b4885f3e973bab29b0027dd6c4fcd8274ff Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Sat, 25 May 2024 22:52:59 +0530 Subject: [PATCH 3/9] fix mssql test failure --- ballerina/tests/init-tests.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/tests/init-tests.bal b/ballerina/tests/init-tests.bal index 56d5834..8d8c838 100644 --- a/ballerina/tests/init-tests.bal +++ b/ballerina/tests/init-tests.bal @@ -434,7 +434,7 @@ AllTypes allTypes4 = { floatType: 63.0, decimalType: 233.44, stringType: "test2", - byteArrayType: base16 `55 EE 66 AF 77 AB`, + byteArrayType: base16 `55 EE 66 FF 77 AB`, dateType: {year: 1996, month: 11, day: 3}, timeOfDayType: {hour: 17, minute: 32, second: 34}, civilType: {year: 1999, month: 11, day: 3, hour: 12, minute: 32, second: 34}, From 3939e4fd0564907aab56a225b36827ca2f186755 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Sat, 25 May 2024 23:02:22 +0530 Subject: [PATCH 4/9] fix test failure --- ballerina/tests/init-tests.bal | 12 +++--- ballerina/tests/mysql-all-types-tests.bal | 2 +- .../tests/postgresql-all-types-tests.bal | 42 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/ballerina/tests/init-tests.bal b/ballerina/tests/init-tests.bal index 8d8c838..5dd6877 100644 --- a/ballerina/tests/init-tests.bal +++ b/ballerina/tests/init-tests.bal @@ -434,18 +434,18 @@ AllTypes allTypes4 = { floatType: 63.0, decimalType: 233.44, stringType: "test2", - byteArrayType: base16 `55 EE 66 FF 77 AB`, + byteArrayType: base16 `55 EE 66 AF 77 AB`, dateType: {year: 1996, month: 11, day: 3}, timeOfDayType: {hour: 17, minute: 32, second: 34}, civilType: {year: 1999, month: 11, day: 3, hour: 12, minute: 32, second: 34}, booleanTypeOptional: true, - intTypeOptional: 35, - floatTypeOptional: 63.0, + intTypeOptional: 6, + floatTypeOptional: 66.0, decimalTypeOptional: 233.44, stringTypeOptional: "test2", - dateTypeOptional: {year: 1996, month: 11, day: 3}, - timeOfDayTypeOptional: {hour: 17, minute: 32, second: 34}, - civilTypeOptional: {year: 1999, month: 11, day: 3, hour: 12, minute: 32, second: 34}, + dateTypeOptional: {year: 1293, month: 11, day: 3}, + timeOfDayTypeOptional: {hour: 19, minute: 32, second: 34}, + civilTypeOptional: {year: 1989, month: 11, day: 3, hour: 12, minute: 32, second: 34}, enumType: "TYPE_1", enumTypeOptional: "TYPE_3" }; diff --git a/ballerina/tests/mysql-all-types-tests.bal b/ballerina/tests/mysql-all-types-tests.bal index 9226831..7339d80 100644 --- a/ballerina/tests/mysql-all-types-tests.bal +++ b/ballerina/tests/mysql-all-types-tests.bal @@ -248,6 +248,6 @@ function mysqlAllTypesDeleteTest() returns error? { AllTypes[] allTypesCollection = check from AllTypes allTypesRecord in allTypesStream select allTypesRecord; - test:assertEquals(allTypesCollection, [allTypes1UpdatedExpected, allTypes3Expected]); + test:assertEquals(allTypesCollection, [allTypes1UpdatedExpected, allTypes3Expected, allTypes4Expected]); check testEntitiesClient.close(); } diff --git a/ballerina/tests/postgresql-all-types-tests.bal b/ballerina/tests/postgresql-all-types-tests.bal index af288fb..e039700 100644 --- a/ballerina/tests/postgresql-all-types-tests.bal +++ b/ballerina/tests/postgresql-all-types-tests.bal @@ -64,7 +64,7 @@ function postgresqlAllTypesReadTest() returns error? { AllTypes[] allTypes = check from AllTypes allTypesRecord in allTypesStream select allTypesRecord; - test:assertEquals(allTypes, [allTypes3Expected, allTypes1Expected, allTypes2Expected, allTypes4Expected]); + test:assertEquals(allTypes, [allTypes3Expected, allTypes4Expected, allTypes1Expected, allTypes2Expected]); check testEntitiesClient.close(); } @@ -99,6 +99,25 @@ function postgresqlAllTypesReadDependentTest() returns error? { timeOfDayTypeOptional: allTypes3Expected.timeOfDayTypeOptional, civilTypeOptional: allTypes3Expected.civilTypeOptional }, + { + booleanType: allTypes4Expected.booleanType, + intType: allTypes4Expected.intType, + floatType: allTypes4Expected.floatType, + decimalType: allTypes4Expected.decimalType, + stringType: allTypes4Expected.stringType, + byteArrayType: allTypes4Expected.byteArrayType, + dateType: allTypes4Expected.dateType, + timeOfDayType: allTypes4Expected.timeOfDayType, + civilType: allTypes4Expected.civilType, + booleanTypeOptional: allTypes4Expected.booleanTypeOptional, + intTypeOptional: allTypes4Expected.intTypeOptional, + floatTypeOptional: allTypes4Expected.floatTypeOptional, + decimalTypeOptional: allTypes4Expected.decimalTypeOptional, + stringTypeOptional: allTypes4Expected.stringTypeOptional, + dateTypeOptional: allTypes4Expected.dateTypeOptional, + timeOfDayTypeOptional: allTypes4Expected.timeOfDayTypeOptional, + civilTypeOptional: allTypes4Expected.civilTypeOptional + }, { booleanType: allTypes1Expected.booleanType, intType: allTypes1Expected.intType, @@ -136,25 +155,6 @@ function postgresqlAllTypesReadDependentTest() returns error? { dateTypeOptional: allTypes2Expected.dateTypeOptional, timeOfDayTypeOptional: allTypes2Expected.timeOfDayTypeOptional, civilTypeOptional: allTypes2Expected.civilTypeOptional - }, - { - booleanType: allTypes4Expected.booleanType, - intType: allTypes4Expected.intType, - floatType: allTypes4Expected.floatType, - decimalType: allTypes4Expected.decimalType, - stringType: allTypes4Expected.stringType, - byteArrayType: allTypes4Expected.byteArrayType, - dateType: allTypes4Expected.dateType, - timeOfDayType: allTypes4Expected.timeOfDayType, - civilType: allTypes4Expected.civilType, - booleanTypeOptional: allTypes4Expected.booleanTypeOptional, - intTypeOptional: allTypes4Expected.intTypeOptional, - floatTypeOptional: allTypes4Expected.floatTypeOptional, - decimalTypeOptional: allTypes4Expected.decimalTypeOptional, - stringTypeOptional: allTypes4Expected.stringTypeOptional, - dateTypeOptional: allTypes4Expected.dateTypeOptional, - timeOfDayTypeOptional: allTypes4Expected.timeOfDayTypeOptional, - civilTypeOptional: allTypes4Expected.civilTypeOptional } ]); check testEntitiesClient.close(); @@ -248,6 +248,6 @@ function postgresqlAllTypesDeleteTest() returns error? { AllTypes[] allTypesCollection = check from AllTypes allTypesRecord in allTypesStream select allTypesRecord; - test:assertEquals(allTypesCollection, [allTypes3Expected, allTypes1UpdatedExpected]); + test:assertEquals(allTypesCollection, [allTypes3Expected, allTypes1UpdatedExpected, allTypes4Expected]); check testEntitiesClient.close(); } From 08cecc46eab0d9282bdaa75d8aaeb8fd07ed0a80 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Sat, 25 May 2024 23:57:33 +0530 Subject: [PATCH 5/9] change the testcase as mssql don't support null in float type --- ballerina/tests/init-tests.bal | 2 +- ballerina/tests/postgresql-all-types-tests.bal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ballerina/tests/init-tests.bal b/ballerina/tests/init-tests.bal index 5dd6877..5506eff 100644 --- a/ballerina/tests/init-tests.bal +++ b/ballerina/tests/init-tests.bal @@ -394,7 +394,7 @@ AllTypes allTypes3 = { civilType: {year: 1999, month: 11, day: 3, hour: 12, minute: 32, second: 34}, booleanTypeOptional: (), intTypeOptional: (), - floatTypeOptional: (), + floatTypeOptional: 66.0, decimalTypeOptional: (), stringTypeOptional: (), dateTypeOptional: (), diff --git a/ballerina/tests/postgresql-all-types-tests.bal b/ballerina/tests/postgresql-all-types-tests.bal index e039700..bbbfce6 100644 --- a/ballerina/tests/postgresql-all-types-tests.bal +++ b/ballerina/tests/postgresql-all-types-tests.bal @@ -248,6 +248,6 @@ function postgresqlAllTypesDeleteTest() returns error? { AllTypes[] allTypesCollection = check from AllTypes allTypesRecord in allTypesStream select allTypesRecord; - test:assertEquals(allTypesCollection, [allTypes3Expected, allTypes1UpdatedExpected, allTypes4Expected]); + test:assertEquals(allTypesCollection, [allTypes3Expected, allTypes4Expected, allTypes1UpdatedExpected]); check testEntitiesClient.close(); } From 37fd3cc8bad5331ecbb9b10f6f7ac8436696df09 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Sun, 26 May 2024 00:09:47 +0530 Subject: [PATCH 6/9] change the testcase as mssql don't support null in date type --- ballerina/tests/init-tests.bal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ballerina/tests/init-tests.bal b/ballerina/tests/init-tests.bal index 5506eff..c31c1d2 100644 --- a/ballerina/tests/init-tests.bal +++ b/ballerina/tests/init-tests.bal @@ -397,9 +397,9 @@ AllTypes allTypes3 = { floatTypeOptional: 66.0, decimalTypeOptional: (), stringTypeOptional: (), - dateTypeOptional: (), - timeOfDayTypeOptional: (), - civilTypeOptional: (), + dateTypeOptional: {year: 1293, month: 11, day: 3}, + timeOfDayTypeOptional: {hour: 19, minute: 32, second: 34}, + civilTypeOptional: {year: 1989, month: 11, day: 3, hour: 12, minute: 32, second: 34}, enumType: "TYPE_1", enumTypeOptional: () }; From 0432eb862e192072186e35016180061c22a4e25b Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Sun, 26 May 2024 00:49:35 +0530 Subject: [PATCH 7/9] Update the failing testcase --- ballerina/tests/mssql-all-types-tests.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/tests/mssql-all-types-tests.bal b/ballerina/tests/mssql-all-types-tests.bal index 9b91c1b..e52499d 100644 --- a/ballerina/tests/mssql-all-types-tests.bal +++ b/ballerina/tests/mssql-all-types-tests.bal @@ -248,6 +248,6 @@ function mssqlAllTypesDeleteTest() returns error? { AllTypes[] allTypesCollection = check from AllTypes allTypesRecord in allTypesStream select allTypesRecord; - test:assertEquals(allTypesCollection, [allTypes1UpdatedExpected, allTypes3Expected]); + test:assertEquals(allTypesCollection, [allTypes1UpdatedExpected, allTypes3Expected, allTypes4Expected]); check testEntitiesClient.close(); } From cd2d9bd789da62455f0a715b8190d899d501825b Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Sun, 26 May 2024 01:03:17 +0530 Subject: [PATCH 8/9] update the changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 5f54d85..d5ca7da 100644 --- a/changelog.md +++ b/changelog.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - [Fix class cast exception when executing query with non-global variable](https://github.com/ballerina-platform/persist-tools/issues/311) - [Updated update query and delete query to support alias table names](https://github.com/ballerina-platform/ballerina-library/issues/6013) +- [Fix the bulk insert failure in sql modules](https://github.com/ballerina-platform/ballerina-library/issues/6563) ## [1.2.0] - 2023-09-18 From 334190aa85b256370c5c9f07d51fbbde470333a5 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 27 May 2024 16:51:41 +0530 Subject: [PATCH 9/9] Add comment with the issue id --- ballerina/tests/init-tests.bal | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ballerina/tests/init-tests.bal b/ballerina/tests/init-tests.bal index c31c1d2..8c117e9 100644 --- a/ballerina/tests/init-tests.bal +++ b/ballerina/tests/init-tests.bal @@ -394,6 +394,8 @@ AllTypes allTypes3 = { civilType: {year: 1999, month: 11, day: 3, hour: 12, minute: 32, second: 34}, booleanTypeOptional: (), intTypeOptional: (), + // Passing () for float, date, time, civil types are not supported in MSSQL connector. + // Issue: https://github.com/ballerina-platform/ballerina-library/issues/6562 floatTypeOptional: 66.0, decimalTypeOptional: (), stringTypeOptional: (),