Skip to content

[Bug]: Null Value retrieval after SELECT a DB query execution does not give any response. #44418

@slahirucd7

Description

@slahirucd7

Description

Hi Team,

public isolated function getBalVersion(http:RequestContext ctx, string componentId, string buildId) returns string?|error {
    sql:ParameterizedQuery query = `SELECT 
                                    BALLERINA_VERSION 
                                    FROM 
                                    COMPONENT_BUILD_MAPPING 
                                    WHERE COMPONENT_ID = ${componentId} AND BUILD_ID = ${buildId}`;

    sql:ExecutionResult|error result = dbClient->queryRow(query);
    if (result is sql:NoRowsError) {
        loggerDb.logDebug(
            ctx,
            string `No build-map found for the build ${buildId} and componentId ${componentId}`,
            constants:DATABASE
        );
        return;
    } else if (result is error) {
        loggerDb.logError(
            ctx,
            string `Error while fetching the Balllerina version for component: ${componentId}`,
            constants:DATABASE,
            result
        );
        return result;
    } else {
        return <string>result.get("BALLERINA_VERSION");
    }
}

We have above method. If the code tries to execute the above condition,
return <string>result.get("BALLERINA_VERSION"); Ballerina Program is not providing any intuitive response and NULL value handling fails.

Steps to Reproduce

No response

Affected Version(s)

2201.10.2

No response

OS, DB, other environment details and versions

MSSQL DB
No response

Related area

-> Compilation

Compilation does not give any error and during the execution time program does not work as we expect.

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions