Skip to content

SNOW-1833760: Statement hasNext and NextResult are incorrectly typed #974

Open
@amardatar

Description

Apologies for omitting the standard questionnaire it's largely irrelevant. This is using version 1.15.0 of the driver.

The driver currently has the FileAndStageBindStatement methods hasNext and NextResult typed incorrectly, as functions that return functions. This is minor, but generates (for example) a linting warning like "Unnecessary conditional, value is always truthy." when attempting to call .hasNext().

For example, the following code shows a linting error:

const connection = snowflake.createConnection({ account: '' });
connection.execute({
    sqlText: 'select 1',
    complete(err, stmt, rows) {
        console.log(rows);
        // typescript-eslint will flag the `stmt.hasNext()` with `Unnecessary conditional, value is always truthy.`
        if ('hasNext' in stmt && stmt.hasNext()) {
            stmt.NextResult();
        }
    },
});

and instead expects to see stmt.hasNext()().

The issue seems to be here where the definitions have an extra set of parentheses. For validation, the source here returns a function, the result of which is assigned to this.hasNext.

Metadata

Labels

bugSomething isn't workingstatus-fixed_awaiting_releaseThe issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector.status-triage_doneInitial triage done, will be further handled by the driver team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions