@samveys/oracle
Dari packages/oracle/README.md di repository framework.
Halaman ini belum diterjemahkan. Kamu sedang membaca versi bahasa Inggris.
Oracle Database driver for @samveys/database. It uses oracledb in thin mode (pure JavaScript, no Instant Client), imported on first connect. The workspace sets allowBuilds: oracledb: false, because thin mode needs no install script.
import { createDatabaseManager, defineDatabaseConfig } from '@samveys/database'
import { oracle } from '@samveys/oracle'
const db = createDatabaseManager(
defineDatabaseConfig({
default: 'main',
connections: { main: oracle({ host: '127.0.0.1', serviceName: 'FREEPDB1', user: 'app', password: process.env.ORACLE_PASSWORD ?? '' }) },
}),
)
const rows = await db.from('users').where('id', 1).get()
console.log(rows.length)
await db.close()Dialect
- Identifiers are quoted in upper case (
"USERS"), the name Oracle gives an unquoted identifier, so raw SQL and builder SQL refer to the same table. Upper-case result labels are folded back to lower case (id,name). - Bindings are
:1, :2, …. Pagination isoffset :n rows fetch next :m rows only(12c+). Derived tables take noas. - No
RETURNING: after an insert the driver reads the generatedidback by ROWID and returns it asinsertId. - Values:
number(1)↔ boolean, integernumber↔number | bigint(every digit kept),date↔Temporal.PlainDate,timestamp↔Temporal.PlainDateTime,timestamp with time zone↔Temporal.Instant. Microseconds are kept: the driver reads the exact wire components, because thin mode's ownDatekeeps milliseconds only. - Sessions run in UTC with ISO NLS formats. Savepoints are
savepoint/rollback to savepoint. DDL commits implicitly (transactionalDdl: false). - Cancellation calls
connection.break()and rejects at once with the abort reason. The connection goes back to the pool only after the interrupted call has ended. - Errors are
SVS_E071with theORA-code inmeta.engineCode(ORA-00001unique,ORA-02291foreign key,ORA-01400not null).
Differences
- Oracle stores
''and zero-length binary values as NULL. The conformance case for empty binary is limited to the other engines for that reason.
Conformance
SVS_REQUIRE_DOCKER=1 node --no-warnings --test packages/oracle/test/conformance.test.ts starts gvenzl/oracle-free:23-slim (native arm64 and x64), runs the conformance cases, and removes the container. The migrations area is skipped: the schema builder has no Oracle catalog queries yet (ADR 0014).