From d501b4f86bc21923caf35e2dea88e3738ea84757 Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Wed, 29 Nov 2023 15:59:39 +0530 Subject: [PATCH 1/2] [Automated] Update native jar versions in toml files --- ballerina/Ballerina.toml | 6 +++--- ballerina/CompilerPlugin.toml | 2 +- ballerina/Dependencies.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 489375dd..6e02b0b0 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "persist" -version = "1.2.0" +version = "1.2.1" authors = ["Ballerina"] keywords = ["persist"] repository = "https://github.com/ballerina-platform/module-ballerina-persist" @@ -15,5 +15,5 @@ graalvmCompatible = true [[platform.java17.dependency]] groupId = "io.ballerina.persist" artifactId = "persist-native" -version = "1.2.0" -path = "../native/build/libs/persist-native-1.2.0.jar" +version = "1.2.1" +path = "../native/build/libs/persist-native-1.2.1-SNAPSHOT.jar" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 6f2a9850..9af387f4 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "persist-compiler-plugin" class = "io.ballerina.stdlib.persist.compiler.PersistCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/persist-compiler-plugin-1.2.0.jar" +path = "../compiler-plugin/build/libs/persist-compiler-plugin-1.2.1-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 1fdf391e..2137098a 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -18,7 +18,7 @@ modules = [ [[package]] org = "ballerina" name = "persist" -version = "1.2.0" +version = "1.2.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] From 264bdff722f23f67359f903f10648610cfb44218 Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Wed, 29 Nov 2023 19:55:09 +0530 Subject: [PATCH 2/2] Add support for postgresql data types --- .../stdlib/persist/compiler/Constants.java | 1 + .../compiler/utils/ValidatorsByDatastore.java | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/compiler/Constants.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/compiler/Constants.java index ae9f92a3..176d2bf8 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/compiler/Constants.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/compiler/Constants.java @@ -71,6 +71,7 @@ public static final class Datastores { public static final String MYSQL = "mysql"; public static final String MSSQL = "mssql"; + public static final String POSTGRESQL = "postgresql"; public static final String IN_MEMORY = "inmemory"; public static final String GOOGLE_SHEETS = "googlesheets"; diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/compiler/utils/ValidatorsByDatastore.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/compiler/utils/ValidatorsByDatastore.java index 9bd5251a..6629d0d0 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/compiler/utils/ValidatorsByDatastore.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/compiler/utils/ValidatorsByDatastore.java @@ -92,6 +92,8 @@ public static boolean isValidSimpleType(String type, String datastore) { return isValidMysqlType(type); case Constants.Datastores.MSSQL: return isValidMssqlType(type); + case Constants.Datastores.POSTGRESQL: + return isValidPostgresqlType(type); case Constants.Datastores.IN_MEMORY: return isValidInMemoryType(type); case Constants.Datastores.GOOGLE_SHEETS: @@ -107,6 +109,8 @@ public static boolean isValidArrayType(String type, String datastore) { return isValidMysqlArrayType(type); case Constants.Datastores.MSSQL: return isValidMssqlArrayType(type); + case Constants.Datastores.POSTGRESQL: + return isValidPostgresqlArrayType(type); case Constants.Datastores.IN_MEMORY: return isValidInMemoryArrayType(type); case Constants.Datastores.GOOGLE_SHEETS: @@ -122,6 +126,8 @@ public static boolean isValidImportedType(String modulePrefix, String identifier return isValidMysqlImportedType(modulePrefix, identifier); case Constants.Datastores.MSSQL: return isValidMssqlImportedType(modulePrefix, identifier); + case Constants.Datastores.POSTGRESQL: + return isValidPostgresqlImportedType(modulePrefix, identifier); case Constants.Datastores.IN_MEMORY: return isValidInMemoryImportedType(modulePrefix, identifier); case Constants.Datastores.GOOGLE_SHEETS: @@ -159,6 +165,21 @@ public static boolean isValidMssqlType(String type) { } } + public static boolean isValidPostgresqlType(String type) { + switch (type) { + case INT: + case BOOLEAN: + case DECIMAL: + case FLOAT: + case STRING: + case ENUM: + return true; + default: + return false; + } + } + + public static boolean isValidInMemoryType(String type) { return true; } @@ -195,6 +216,16 @@ public static boolean isValidMssqlArrayType(String type) { } } + public static boolean isValidPostgresqlArrayType(String type) { + switch (type) { + case BYTE: + return true; + default: + return false; + } + } + + public static boolean isValidInMemoryArrayType(String type) { return true; } @@ -233,6 +264,22 @@ public static boolean isValidMssqlImportedType(String modulePrefix, String ident } } + public static boolean isValidPostgresqlImportedType(String modulePrefix, String identifier) { + if (!modulePrefix.equals(TIME_MODULE)) { + return false; + } + switch (identifier) { + case DATE: + case TIME_OF_DAY: + case UTC: + case CIVIL: + return true; + default: + return false; + } + } + + public static boolean isValidInMemoryImportedType(String modulePrefix, String identifier) { return true; }