Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
amardatar opened this issue Nov 28, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working status-triage_done Initial triage done, will be further handled by the driver team

Comments

@amardatar
Copy link

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.

@amardatar amardatar added the bug Something isn't working label Nov 28, 2024
@github-actions github-actions bot changed the title Statement hasNext and NextResult are incorrectly typed SNOW-1833760: Statement hasNext and NextResult are incorrectly typed Nov 28, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage_done Initial triage done, will be further handled by the driver team label Nov 28, 2024
@sfc-gh-dszmolka
Copy link
Collaborator

hi - thank you for pointing this out; and also for providing the details! we'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants