dbos-inc / dbos-transact-ts

The TypeScript framework for backends that scale
https://docs.dbos.dev
MIT License
373 stars 28 forks source link

@StoredProcedures can't invoke queries w/ zero parameters #636

Closed devhawk closed 1 month ago

devhawk commented 1 month ago

Example:

  @StoredProcedure({readOnly: true})
  static async getHelloRowCount(ctxt: StoredProcedureContext): Promise<number> {
    const query = "SELECT COUNT(*) FROM dbos_hello;";
    const { rows } = await ctxt.query<{count: number}>(query);
    return rows[0].count;

results in an error parameter numbers mismatch: 0 != 1.

devhawk commented 1 month ago

Note, until the fix is merged and released, the workaround is to include an empty array as the first parameter

  @StoredProcedure({readOnly: true})
  static async getHelloRowCount(ctxt: StoredProcedureContext): Promise<number> {
    const query = "SELECT COUNT(*) FROM dbos_hello;";
    const { rows } = await ctxt.query<{count: number}>(query, []);
    return rows[0].count;