Skip to content

Commit

Permalink
Fix class cast expression for use of local variables
Browse files Browse the repository at this point in the history
  • Loading branch information
niveathika committed Oct 17, 2023
1 parent 6912f48 commit c1dd245
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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
- [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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ 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;

Check warning on line 214 in compiler-plugin/src/main/java/io/ballerina/stdlib/persist/sql/compiler/codemodifier/PersistQueryValidator.java

View check run for this annotation

Codecov / codecov/patch

compiler-plugin/src/main/java/io/ballerina/stdlib/persist/sql/compiler/codemodifier/PersistQueryValidator.java#L214

Added line #L214 was not covered by tests
}
SimpleNameReferenceNode clientName = (SimpleNameReferenceNode) remoteCall.expression();
Collection<ChildNodeEntry> clientResourceChildEntries = remoteCall.childEntries();
if (clientResourceChildEntries.size() == 5 || clientResourceChildEntries.size() == 7) {
Expand Down

0 comments on commit c1dd245

Please sign in to comment.