Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/actions.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is machine-generated by `gh actions-lock`.
# Do not edit by hand; run `gh actions-lock` to update.
# Docs: https://gh.io/actions-lockfile
version: 'v0.0.2'
workflows:
'.github/workflows/ci.yaml':
- 'actions/checkout@v7.0.1'
- 'actions/setup-node@v7.0.0'
- 'step-security/harden-runner@v2.20.1'
dependencies:
'actions/checkout@v7.0.1':
ref: 'v7.0.1'
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
owner_id: 44036562
repo_id: 197814629
'actions/setup-node@v7.0.0':
ref: 'v7.0.0'
commit: 'sha1-820762786026740c76f36085b0efc47a31fe5020'
owner_id: 44036562
repo_id: 189476904
'step-security/harden-runner@v2.20.1':
ref: 'v2.20.1'
commit: 'sha1-b09bb98e06d4d774595224525879c09bc6e98c40'
owner_id: 88700172
repo_id: 422287306
72 changes: 72 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This workflow is managed by gh actions-lock.

on:
push:
branches:
- master
pull_request: {}

name: CI

permissions: {}

jobs:
test:
name: Test
strategy:
matrix:
os: [ubuntu-latest]
node-version: [24]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
permissions:
contents: read
services:
oracle-db:
image: container-registry.oracle.com/database/free:latest
ports:
- 1521:1521
options: >-
--name oracle_free_db
--env ORACLE_PWD=0raclep4ss
--health-cmd /opt/oracle/checkDBStatus.sh
--health-timeout 5s
--health-retries 5
steps:
- uses: step-security/harden-runner@v2.20.1
with:
disable-sudo: true
egress-policy: audit
- uses: actions/checkout@v7.0.1
- uses: actions/setup-node@v7.0.0
with:
node-version: ${{ matrix.node-version }}
- name: Bootstrap Dependencies
run: npm ci
- name: Run Tests
env:
DOCKER_CLI: docker
SKIP_DB_CONTAINER_CREATION: 1
run: |-
. ./setup.sh
npm test

code-lint:
name: Code Lint
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- uses: step-security/harden-runner@v2.20.1
with:
disable-sudo: true
egress-policy: audit
- uses: actions/checkout@v7.0.1
- uses: actions/setup-node@v7.0.0
with:
node-version: 24
- name: Bootstrap Dependencies
run: npm ci --ignore-scripts
- name: Check Code Lint
run: npm run lint
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ docs
*.tgz
.loopbackrc
node_modules

\#*
.#*
*~
12 changes: 10 additions & 2 deletions lib/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ module.exports = mixinMigration;

function mixinMigration(Oracle) {
Oracle.prototype.showFields = function(model, cb) {
const sqlTableNameFilter = ' WHERE table_name=\'' +
this.table(model) + '\'';

const owner = this.schema(model);
const sqlOwnerFilter = owner !== '' ? ' AND owner=\'' + owner + '\'' : '';
const sqlTabColumnsTable = owner !== '' ? 'ALL' : 'USER';

const sql = 'SELECT column_name AS "column", data_type AS "type",' +
' data_length AS "length", nullable AS "nullable"' + // , data_default AS "Default"'
' FROM "SYS"."USER_TAB_COLUMNS" WHERE table_name=\'' +
this.table(model) + '\'';
' FROM "SYS"."' + sqlTabColumnsTable + '_TAB_COLUMNS"' +
sqlTableNameFilter + sqlOwnerFilter;

this.execute(sql, function(err, fields) {
if (err)
return cb(err);
Expand Down
22 changes: 20 additions & 2 deletions lib/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ const debug = require('debug')('loopback:connector:oracle');
const stream = require('stream');
const async = require('async');

// Oracle `date` type does not store timezone information.
// This connector always stores DATE in UTC, but `oracledb@6` onwards
// retrieves it as if it's local timezone.
// This fetch type handler corrects for this.
oracle.fetchTypeHandler = function(metadata) {
if (metadata.dbType === oracle.DB_TYPE_DATE) {
return {
converter: (val) => {
if (val !== null) {
console.log(val.getTimezoneOffset());
val.setMinutes(val.getMinutes() - val.getTimezoneOffset());
}
return val;
},
};
}
};

/*!
* @module loopback-connector-oracle
*
Expand Down Expand Up @@ -52,7 +70,7 @@ exports.initialize = function initializeDataSource(dataSource, callback) {
queueRequests: undefined,
queueTimeout: undefined,
stmtCacheSize: undefined,
_enableStats: undefined,
enableStatistics: undefined,
};

const oracleSettings = {
Expand All @@ -68,7 +86,7 @@ exports.initialize = function initializeDataSource(dataSource, callback) {
outFormat: oracle.OBJECT,
maxRows: s.maxRows || 0,
stmtCacheSize: s.stmtCacheSize || 30,
_enableStats: s._enableStats || false,
enableStatistics: s.enableStatistics || false,
connectionClass: 'loopback-connector-oracle',
};

Expand Down
Loading
Loading