Skip to content

Commit

Permalink
Merge pull request #592 from ballerina-platform/update4
Browse files Browse the repository at this point in the history
Sync master branch with update4 branch
  • Loading branch information
niveathika authored Nov 29, 2022
2 parents c5c1020 + 1b9a683 commit de190e4
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 101 deletions.
10 changes: 5 additions & 5 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[package]
org = "ballerina"
name = "sql"
version = "1.6.0"
version = "1.7.0"
authors = ["Ballerina"]
keywords = ["database", "client", "network", "SQL", "RDBMS"]
repository = "https://github.com/ballerina-platform/module-ballerina-sql"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.3.0"
distribution = "2201.4.0"

[[platform.java11.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "sql-native"
version = "1.6.0"
path = "../native/build/libs/sql-native-1.6.0.jar"
version = "1.7.0"
path = "../native/build/libs/sql-native-1.7.0-SNAPSHOT.jar"

[[platform.java11.dependency]]
path = "../test-utils/build/libs/sql-test-utils-1.6.0.jar"
path = "../test-utils/build/libs/sql-test-utils-1.7.0-SNAPSHOT.jar"
scope = "testOnly"

[[platform.java11.dependency]]
Expand Down
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.6.0.jar"
path = "../compiler-plugin/build/libs/sql-compiler-plugin-1.7.0-SNAPSHOT.jar"
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "sql"
version = "1.6.0"
version = "1.7.0"
dependencies = [
{org = "ballerina", name = "file"},
{org = "ballerina", name = "io"},
Expand Down
2 changes: 1 addition & 1 deletion build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["database", "client", "network", "SQL", "RDBMS"]
repository = "https://github.com/ballerina-platform/module-ballerina-sql"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.3.0"
distribution = "2201.4.0"

[[platform.java11.dependency]]
groupId = "io.ballerina.stdlib"
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

### Changed
- [Remove SQL_901 diagnostic hint](https://github.com/ballerina-platform/ballerina-standard-library/issues/3609)

## [1.6.0] - 2022-11-29

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import java.util.List;
import java.util.stream.Collectors;

import static io.ballerina.stdlib.sql.compiler.SQLDiagnosticsCodes.SQL_901;

/**
* Tests the custom SQL compiler plugin.
*/
Expand Down Expand Up @@ -121,32 +119,6 @@ public void testOutParameterValidations() {
Assert.assertEquals(timeWithTimezoneOutParameter.messageFormat(), SQLDiagnosticsCodes.SQL_231.getMessage());
}

@Test
public void testOutParameterHint() {
Package currentPackage = loadPackage("sample3");
PackageCompilation compilation = currentPackage.getCompilation();
DiagnosticResult diagnosticResult = compilation.diagnosticResult();
List<Diagnostic> errorDiagnosticsList = diagnosticResult.diagnostics().stream()
.filter(r -> r.diagnosticInfo().severity().equals(DiagnosticSeverity.ERROR))
.collect(Collectors.toList());
long availableErrors = errorDiagnosticsList.size();

Assert.assertEquals(availableErrors, 2);

List<Diagnostic> hintDiagnosticsList = diagnosticResult.diagnostics().stream()
.filter(r -> r.diagnosticInfo().severity().equals(DiagnosticSeverity.HINT))
.collect(Collectors.toList());
long availableHints = hintDiagnosticsList.size();

Assert.assertEquals(availableHints, 2);

hintDiagnosticsList.forEach(diagnostic -> {
Assert.assertEquals(diagnostic.diagnosticInfo().code(), SQL_901.getCode());
Assert.assertEquals(diagnostic.diagnosticInfo().messageFormat(), SQL_901.getMessage());
});

}

@Test
public void testConnectionPoolWithVariable() {
Package currentPackage = loadPackage("sample4");
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import io.ballerina.tools.diagnostics.DiagnosticSeverity;

import static io.ballerina.tools.diagnostics.DiagnosticSeverity.ERROR;
import static io.ballerina.tools.diagnostics.DiagnosticSeverity.HINT;

/**
* Enum class to hold SQL module diagnostic codes.
Expand All @@ -43,9 +42,7 @@ public enum SQLDiagnosticsCodes {
SQL_221("SQL_221", "invalid value: expected value is any one of boolean, int or string", ERROR),
SQL_222("SQL_222", "invalid value: expected value is any one of time:Date, int or string", ERROR),
SQL_223("SQL_223", "invalid value: expected value is any one of time:TimeOfDay, int or string", ERROR),
SQL_231("SQL_231", "invalid value: expected value is any one of time:Civil, time:Utc, int or string", ERROR),

SQL_901("SQL_901", "parameter 'typeDesc' should be explicitly passed when the return data is ignored", HINT);
SQL_231("SQL_231", "invalid value: expected value is any one of time:Civil, time:Utc, int or string", ERROR);

private final String code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,10 @@
import io.ballerina.tools.diagnostics.Diagnostic;
import io.ballerina.tools.diagnostics.DiagnosticFactory;
import io.ballerina.tools.diagnostics.DiagnosticInfo;
import io.ballerina.tools.diagnostics.DiagnosticSeverity;

import java.util.List;
import java.util.Optional;

import static io.ballerina.stdlib.sql.compiler.SQLDiagnosticsCodes.SQL_901;
import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.CANNOT_INFER_TYPE_FOR_PARAM;
import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.INCOMPATIBLE_TYPE_FOR_INFERRED_TYPEDESC_VALUE;

/**
* Code Analyser for OutParameter get method type validations.
*/
Expand All @@ -52,14 +47,7 @@ public void perform(SyntaxNodeAnalysisContext ctx) {
MethodCallExpressionNode node = (MethodCallExpressionNode) ctx.node();
List<Diagnostic> diagnostics = ctx.semanticModel().diagnostics();
if (!diagnostics.isEmpty()) {
diagnostics.stream()
.filter(diagnostic -> diagnostic.diagnosticInfo().severity() == DiagnosticSeverity.ERROR)
.filter(diagnostic ->
diagnostic.diagnosticInfo().code().equals(CANNOT_INFER_TYPE_FOR_PARAM.diagnosticId()) ||
diagnostic.diagnosticInfo().code().equals(
INCOMPATIBLE_TYPE_FOR_INFERRED_TYPEDESC_VALUE.diagnosticId()))
.filter(diagnostic -> diagnostic.location().lineRange().equals(node.location().lineRange()))
.forEach(diagnostic -> addHint(ctx, node));
return;
}

// Get the object type to validate arguments
Expand Down Expand Up @@ -106,19 +94,6 @@ public void perform(SyntaxNodeAnalysisContext ctx) {
}
}

private void addHint(SyntaxNodeAnalysisContext ctx, MethodCallExpressionNode node) {
if (!(Utils.isSQLOutParameter(ctx, node.expression()))) {
return;
}

if (isGetMethod(ctx, node)) {
return;
}

ctx.reportDiagnostic(DiagnosticFactory.createDiagnostic(
new DiagnosticInfo(SQL_901.getCode(), SQL_901.getMessage(), SQL_901.getSeverity()), node.location()));
}

private boolean isGetMethod(SyntaxNodeAnalysisContext ctx, MethodCallExpressionNode node) {
Optional<Symbol> methodSymbol = ctx.semanticModel().symbol(node.methodName());
if (methodSymbol.isEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=io.ballerina.stdlib
version=1.6.1-SNAPSHOT
version=1.7.0-SNAPSHOT

puppycrawlCheckstyleVersion=8.18
hikkariLibVersion=3.3.1
Expand All @@ -14,7 +14,7 @@ researchgateReleaseVersion=2.8.0
testngVersion=7.4.0
ballerinaGradlePluginVersion=0.14.1

ballerinaLangVersion=2201.3.0
ballerinaLangVersion=2201.4.0-20221104-003000-4b73c40e

# Direct Dependencies
# Level 01
Expand Down

0 comments on commit de190e4

Please sign in to comment.