diff --git a/changelog.md b/changelog.md index f15edfd..1121bba 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed +- [Fix class cast exception when executing query with non-global variable](https://github.com/ballerina-platform/persist-tools/issues/311) ## [1.2.0] - 2023-09-18 diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/sql/compiler/codemodifier/PersistQueryValidator.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/sql/compiler/codemodifier/PersistQueryValidator.java index e6c7def..c891fec 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/sql/compiler/codemodifier/PersistQueryValidator.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/persist/sql/compiler/codemodifier/PersistQueryValidator.java @@ -208,6 +208,10 @@ public void perform(SyntaxNodeAnalysisContext ctx) { private Query isQueryUsingPersistentClient(FromClauseNode fromClauseNode) { if (fromClauseNode.expression() instanceof ClientResourceAccessActionNode remoteCall) { + if (remoteCall.expression().kind() != SyntaxKind.SIMPLE_NAME_REFERENCE) { + // This improvement is tracked in https://github.com/ballerina-platform/ballerina-standard-library/issues/4943 + return null; + } SimpleNameReferenceNode clientName = (SimpleNameReferenceNode) remoteCall.expression(); Collection clientResourceChildEntries = remoteCall.childEntries(); if (clientResourceChildEntries.size() == 5 || clientResourceChildEntries.size() == 7) {