Skip to content

Add Explicit Resource Management to oracledb objects #1631

Open
@sosoba

Description

@sosoba
  1. Describe your new request in detail

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

await using pool = await oracledb.createPool({...});
await using connection = await pool.getConnection();
const { rows = [] } = await connection.execute( 'SELECT b FROM no_lobs WHERE id = :id', { id: 2 });
await using lob = rows[0][0];
lob.pipe(response);

which is equivalent to:

const pool = await oracledb.createPool({...});
try {
  const connection = await pool.getConnection();
  try {
    const { rows }= await connection.execute( 'SELECT b FROM no_lobs WHERE id = :id', { id: 2 });
    const lob = rows[0][0];
    try {
      lob.pipe(response);
    } finally {
      lob.destroy();
    }
  } 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