Skip to content

Commit

Permalink
Address review suggstions
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhashinee committed Apr 1, 2024
1 parent 7f04b4c commit 19832c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ public void perform(SyntaxNodeAnalysisContext ctx) {
try {
datastore = getDatastore(ctx);
} catch (BalException e) {
if (e.getMessage().contains("the persist.datastore configuration does not exist")) {
return;
}
throw new RuntimeException(e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private static String getDataStoreName(Path configPath) throws BalException {
}
}
}
throw new BalException("the persist.datastore configuration does not exist in the Ballerina.toml file");
return null;
} catch (IOException e) {
throw new BalException("error while reading persist configurations. " + e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static boolean validateSimpleTypes(Entity entity, Node typeNode, String t
List<DiagnosticProperty<?>> properties, String type, String datastore) {
boolean validFlag = true;

if (isOptionalType && datastore.equals(Constants.Datastores.GOOGLE_SHEETS)) {
if (isOptionalType && Constants.Datastores.GOOGLE_SHEETS.equals(datastore)) {
entity.reportDiagnostic(PERSIST_308.getCode(),
MessageFormat.format(PERSIST_308.getMessage(), type),
PERSIST_308.getSeverity(), typeNode.location(), properties);
Expand Down Expand Up @@ -87,6 +87,10 @@ public static boolean validateSimpleTypes(Entity entity, Node typeNode, String t
}

public static boolean isValidSimpleType(String type, String datastore) {
// If the datastore is null(ex: generate command), ignore the data type validation.
if (null == datastore) {
return true;
}
switch (datastore) {
case Constants.Datastores.MYSQL:
return isValidMysqlType(type);
Expand All @@ -104,6 +108,10 @@ public static boolean isValidSimpleType(String type, String datastore) {
}

public static boolean isValidArrayType(String type, String datastore) {
// If the datastore is null(ex: generate command), ignore the data type validation.
if (null == datastore) {
return true;
}
switch (datastore) {
case Constants.Datastores.MYSQL:
return isValidMysqlArrayType(type);
Expand All @@ -121,6 +129,10 @@ public static boolean isValidArrayType(String type, String datastore) {
}

public static boolean isValidImportedType(String modulePrefix, String identifier, String datastore) {
// If the datastore is null(ex: generate command), ignore the data type validation.
if (null == datastore) {
return true;
}
switch (datastore) {
case Constants.Datastores.MYSQL:
return isValidMysqlImportedType(modulePrefix, identifier);
Expand Down

0 comments on commit 19832c0

Please sign in to comment.