-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Typescript Definition now available for 4.0 #1136
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
Comments
One thing to note... Due to the refactoring in 4.0, using both default and named exports will result in the named exports being undefined. For example:
This will result in OUT_FORMAT_OBJECT being undefined.
|
Have you considered enriching the declaration with generic types for the result (with default Row type). Something like: interface Result<R> {
rows: R[];
}
execute<R=Row>(sql: string, bindParams: BindParameters, options: ExecuteOptions): Promise<Result<R>>; this would allow queries to be typed: const res = await connection.execute<{X:string}>( 'SELECT X from DUAL' ); |
Good idea! See PR #37747 |
I don't know if this is a good place for further comments.
attribute to MetaData result. Type - string, It contains the name of the type the column has in the database, such as "VARCHAR2". |
I have a litle issue: Record in line 581: type BindParameters = Record<string, BindParameter | string | number | Date | DBObject | Buffer | null> | BindParameter[] | any[]; should also prevent |
@sosoba Could you send me a code snippet as I'm not sure what you mean? The types do currently prevent bind parameters being undefined |
This js snippet print "1" because oracledb allow to pass const oracledb = require('oracledb');
(async function(){
const conn = await oracledb.getConnection({user:'TEST',password:'TEST',connectString:'localhost:1521/XE'});
const res = await conn.execute('SELECT * FROM DUAL where :p1 is null and :p2 is null', {
p1:null,
p2:undefined,
});
console.log(res.rows.length);
})(); Type definition for |
It’s correct to flag it as a mistake, as oracledb ignores undefined bind parameters. You’ll get an error saying not all variables bound. You can test this by doing |
I'm trying again: {
p1: null,
} give me {
p1: null,
p2: undefined as any
} give me success. Oracledb translate undefined to null. Object.keys( { p1 : null, p2 : undefined } ); // [ 'p1', 'p2' ] |
Just tried again and you're right, it was treated as null. I'm sure I tried that yesterday! |
Thank you. |
I have a doubt about oracledb-tests.ts. Assert at line 160: assert.deepStrictEqual(row, [1]); is based on select without |
Regadles to documentation:
Could you add question marks to other fields than |
Updates for node-oracledb 4.1 got merged: DefinitelyTyped/DefinitelyTyped#40653 Thank you @connorjayfitzgerald ! |
@connorjayfitzgerald has got a TypeScript PR ready for node-oracledb 5: DefinitelyTyped/DefinitelyTyped#45781 I think I'll close this old announcement issue - otherwise it could remain open forever! |
The DefinitelyTyped definition for oracledb 4.0 has now been merged and is available to use.
https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/oracledb
The text was updated successfully, but these errors were encountered: