Skip to content

SNOW-1842116: Typescript: getResultsFromQueryId expects option of type StatementOption. sqlText should therefore be optional. #978

Open
@sjclemmy

Description

@sjclemmy

The typescript type for the connect.getResultsFromQueryId options argument is StatementOption, This is shared with connection.execute so I would expect the sqlText to be optional.

It would probably be a better idea to give getResultsFromQueryId its own argument type.
This code yields a typescript error

    connection.getResultsFromQueryId({
      queryId: queryId,
      complete: function (err, stmt, rows) {
        if (err) {
          console.error(
            "Failed to execute statement due to the following error: " +
              err.message
          );
        } else {
          console.log(rows);
        }
      },
    });
Argument of type '{ queryId: string; complete: (err: SnowflakeError | undefined, stmt: RowStatement | FileAndStageBindStatement, rows: any[] | undefined) => void; }' is not assignable to parameter of type 'StatementOption'.
  Property 'sqlText' is missing in type '{ queryId: string; complete: (err: SnowflakeError | undefined, stmt: RowStatement | FileAndStageBindStatement, rows: any[] | undefined) => void; }' but required in type 'StatementOption'.ts(2345)
index.d.ts(604, 9): 'sqlText' is declared here.

This code passes the typescript validation, but I don't know if it actually works.

    connection.getResultsFromQueryId({
      // not optional (bug) so need to pass empty string
      sqlText: "",
      queryId: queryId,
      complete: function (err, stmt, rows) {
        if (err) {
          console.error(
            "Failed to execute statement due to the following error: " +
              err.message
          );
          reject(err);
        } else {
          resolve(rows);
        }
      },
    });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingstatus-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