Skip to content

Add Explicit Resource Management to oracledb objects #1631

@sosoba

Description

@sosoba
  1. Describe your new request in detail

TS/JS, like other programming languages, introduced a syntax for automated resource release (using). Ex.:

await using pool = await oracledb.createPool({...});
await using connection = await pool.getConnection();
const { resultSet } = await connection.execute( 'SELECT ...', {}, { resultSet: true });
await using rs = resultSet;
await rs.getRows();

what replaces:

const pool = await oracledb.createPool({...});
try {
  const connection = await pool.getConnection();
  try {
    const { resultSet } = await connection.execute( 'SELECT ...', {}, { resultSet: true });
    try {
      await rs.getRows();
    } finally {
      resultSet.close();
    }
  } finally {
    await connection.close();
  }
} finally {
  await pool.close();
}

I think it is worth expanding the library to support this solution.

  1. Give supporting information about tools.

The implementation involves adding aliased symbolic methods to close / destroy. See:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management
https://tc39.es/proposal-explicit-resource-management/

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