juanluispaz / ts-sql-query

Type-safe SQL query builder like QueryDSL or JOOQ in Java or Linq in .Net for TypeScript with MariaDB, MySql, Oracle, PostgreSql, Sqlite and SqlServer support.
https://ts-sql-query.readthedocs.io/
MIT License
283 stars 18 forks source link

Column with type `bigint` not working properly with Oracle NUMBER #126

Open jameschenjav opened 4 months ago

jameschenjav commented 4 months ago

oracledb version is 6.4.0

Table definition:

class Foo extends Table<DBConnection, 'Foo'> {
  id = this.column('id', 'bigint') // NUMBER
}

const tFoo = new Foo();

const bar = await connection
      .selectFrom(tFoo)
      .select({ id: tFoo.id })
      .where(tFoo.id.equals(1000n))
      .executeSelectOne();

It raises exception

ChainedError: NJS-044: bind object must contain one of the following attributes: "dir", "type", "maxSize", or "val"
    at .../node_modules/.pnpm/ts-sql-query@1.64.0/node_modules/ts-sql-query/queryBuilders/SelectQueryBuilder.js:119:60
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at main (.../app/main.ts:24:16)
Caused By: Error: NJS-044: bind object must contain one of the following attributes: "dir", "type", "maxSize", or "val"
    at Object.throwErr (.../node_modules/.pnpm/oracledb@6.4.0/node_modules/oracledb/lib/errors.js:617:10)
    ... 5 lines matching cause stack trace ...
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Source: Error: Query executed at
    at SelectQueryBuilder.executeSelectOne (.../node_modules/.pnpm/ts-sql-query@1.64.0/node_modules/ts-sql-query/queryBuilders/SelectQueryBuilder.js:91:24)
    at main (.../app/main.ts:28:8)
juanluispaz commented 4 months ago

Hi,

Can you update to oracledb 6.5.0? In that version, they added support for bigint.

Release notes: https://node-oracledb.readthedocs.io/en/latest/release_notes.html#node-oracledb-v6-5-0-2-may-2024 (point 8) More information: https://node-oracledb.readthedocs.io/en/latest/user_guide/bind.html#bind-data-type-notes

Let me know if that works for you.