Skip to content

Commit 5f621d7

Browse files
fix(oracle): add support for Oracle DB 18c CI (#15016)
* feat(oracle): add oracle dialect support (#1) * feat(oracle): add oracle dialect support * fix: addressing review comments (#7) * fix: addressing review comments * fix: minor fixes done (#9) * fix: minor fixes to the review comments * fix: merge from sequelize-v6 * fix: enable newly added unit tests for Oracle dialect * fix: remove dangling comma (#13) * fix: doc gen is fixed * fix: autogenerate the primary constraint name (#14) * fix: autogenerate the primary constraint name * fix: remove trailing comma * fix: make changes to ORADERBY as per v6 sync * fix: move test-unit-oracle above test-unit-all * fix: rename getInsertQueryReturnIntoBinds to populateInsertQueryReturnIntoBinds * fix: reorder parameters for function populateInsertQueryReturnIntoBinds * fix: incorporated review comments (#16) * fix: incorporated review comments * fix: modify string empty check with ! * feat: support for Oracle DB 18c * Oracle DB version change * added stop-oracle for 18 * fix: changes to DB version query * fix: cleanup * fix: describetable query fix * fix: dbVersion to remove round trip and 18.4 json test fix * fix: removed dbversion * fix: removed comment * fix: testing a feature * fix: testing a feature * fix: testing a feature * fix: testing a feature * fix: testing a feature * fix: testing a feature * fix: test * fix: test * fix: test * fix: test * fix: using semver to coerce version sring * fix: update to instant client latest version for oracle db 21c * fix: update to oracledb version in package.json * fix: update lockfile * fix: remove duplicate privileges.sql and wait-until-healthy.sh * fix: changes to start-oracle alias * fix: changes to start-oracle alias * fix: changes to start-oracle alias Co-authored-by: Sudarshan Soma <48428602+sudarshan12s@users.noreply.github.com>
1 parent 3468378 commit 5f621d7

File tree

14 files changed

+127
-21
lines changed

14 files changed

+127
-21
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ jobs:
5151
strategy:
5252
fail-fast: false
5353
matrix:
54+
oracle-version: [18, 21]
5455
node-version: [10, 18]
55-
name: Oracle DB (Node ${{ matrix.node-version }})
56+
name: Oracle DB ${{ matrix.oracle-version }} (Node ${{ matrix.node-version }})
5657
runs-on: ubuntu-latest
5758
env:
5859
DIALECT: oracle
@@ -69,8 +70,12 @@ jobs:
6970
with:
7071
node-version: ${{ matrix.node-version }}
7172
- run: yarn install --frozen-lockfile --ignore-engines
72-
- name: Install Local Oracle DB
73-
run: yarn start-oracle
73+
- if: matrix.oracle-version == '18'
74+
name: Install Local Oracle DB 18
75+
run: yarn start-oracle-oldest
76+
- if: matrix.oracle-version == '21'
77+
name: Install Local Oracle DB 21
78+
run: yarn start-oracle-latest
7479
- name: Unit Tests
7580
run: yarn test-unit
7681
- name: Integration Tests
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved
2+
3+
services:
4+
oraclexedb:
5+
container_name: oraclexedb
6+
image: gvenzl/oracle-xe:18-slim
7+
environment:
8+
ORACLE_PASSWORD: password
9+
ports:
10+
- 1521:1521
11+
healthcheck:
12+
test: ["CMD-SHELL", "sqlplus", "system/password@XEPDB1"]
13+
retries: 10
14+
15+
networks:
16+
default:
17+
name: sequelize-oraclexedb-network

dev/oracle/18-slim/start.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved
2+
3+
#!/usr/bin/env bash
4+
set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
5+
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637
6+
7+
# Remove an existing Oracle DB docker image
8+
docker-compose -p oraclexedb down --remove-orphans
9+
10+
# Bring up new Oracle DB docker image
11+
docker-compose -p oraclexedb up -d
12+
13+
# Wait until Oracle DB is set up and docker state is healthy
14+
./../wait-until-healthy.sh oraclexedb
15+
16+
# Moving privileges.sql to docker container
17+
docker cp ../privileges.sql oraclexedb:/opt/oracle/.
18+
19+
# Granting all the needed privileges to sequelizetest user
20+
docker exec -t oraclexedb sqlplus system/password@XEPDB1 @privileges.sql
21+
22+
SEQ_WORKSPACE="$PWD"/../../../
23+
24+
if [[ ! -d "$SEQ_WORKSPACE"/.oracle/ ]]
25+
then
26+
mkdir "$SEQ_WORKSPACE"/.oracle/
27+
if [[ $(uname) == 'Linux' ]]
28+
then
29+
wget https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basic-linux.x64-21.7.0.0.0dbru.zip --no-check-certificate &&
30+
unzip instantclient-basic-linux.x64-21.7.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ &&
31+
rm instantclient-basic-linux.x64-21.7.0.0.0dbru.zip &&
32+
mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_7 "$SEQ_WORKSPACE"/.oracle/instantclient
33+
34+
echo "Local Oracle instant client on Linux has been setup!"
35+
elif [[ $(uname) == 'Darwin' ]]
36+
then
37+
if [[ ! -d ~/Downloads/instantclient_19_8 ]]
38+
then
39+
curl -O https://download.oracle.com/otn_software/mac/instantclient/198000/instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg &&
40+
hdiutil mount instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg &&
41+
/Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru/install_ic.sh &&
42+
hdiutil unmount /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru &&
43+
rm instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg &&
44+
mv ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient
45+
else
46+
cp -rf ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient
47+
fi
48+
ln -s "$SEQ_WORKSPACE"/.oracle/instantclient/libclntsh.dylib "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release/
49+
50+
echo "Local Oracle instant client on macOS has been setup!"
51+
else
52+
# Windows
53+
curl -O https://download.oracle.com/otn_software/nt/instantclient/216000/instantclient-basic-windows.x64-21.6.0.0.0dbru.zip &&
54+
unzip instantclient-basic-windows.x64-21.6.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ &&
55+
rm instantclient-basic-windows.x64-21.6.0.0.0dbru.zip &&
56+
mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_6/* "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release
57+
58+
echo "Local Oracle instant client on $(uname) has been setup!"
59+
fi
60+
fi
61+
echo "Local Oracle DB is ready for use!"

dev/oracle/18-slim/stop.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved
2+
3+
#!/usr/bin/env bash
4+
set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
5+
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637
6+
7+
8+
docker-compose -p oraclexedb down --remove-orphans
9+
10+
echo "Local Oracle DB instance stopped (if it was running)."

dev/oracle/21-slim/start.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ docker-compose -p oraclexedb down --remove-orphans
1111
docker-compose -p oraclexedb up -d
1212

1313
# Wait until Oracle DB is set up and docker state is healthy
14-
./wait-until-healthy.sh oraclexedb
14+
./../wait-until-healthy.sh oraclexedb
1515

1616
# Moving privileges.sql to docker container
17-
docker cp privileges.sql oraclexedb:/opt/oracle/.
17+
docker cp ../privileges.sql oraclexedb:/opt/oracle/.
1818

1919
# Granting all the needed privileges to sequelizetest user
2020
docker exec -t oraclexedb sqlplus system/password@XEPDB1 @privileges.sql
@@ -26,10 +26,10 @@ then
2626
mkdir "$SEQ_WORKSPACE"/.oracle/
2727
if [[ $(uname) == 'Linux' ]]
2828
then
29-
wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip --no-check-certificate &&
30-
unzip instantclient-basic-linux.x64-21.6.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ &&
31-
rm instantclient-basic-linux.x64-21.6.0.0.0dbru.zip &&
32-
mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_6 "$SEQ_WORKSPACE"/.oracle/instantclient
29+
wget https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basic-linux.x64-21.7.0.0.0dbru.zip --no-check-certificate &&
30+
unzip instantclient-basic-linux.x64-21.7.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ &&
31+
rm instantclient-basic-linux.x64-21.7.0.0.0dbru.zip &&
32+
mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_7 "$SEQ_WORKSPACE"/.oracle/instantclient
3333

3434
echo "Local Oracle instant client on Linux has been setup!"
3535
elif [[ $(uname) == 'Darwin' ]]

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"mysql2": "^2.3.3",
107107
"node-hook": "^1.0.0",
108108
"nyc": "^15.1.0",
109-
"oracledb": "^5.4.0",
109+
"oracledb": "^5.5.0",
110110
"p-map": "^4.0.0",
111111
"p-props": "^4.0.0",
112112
"p-settle": "^4.1.1",
@@ -244,20 +244,23 @@
244244
"start-postgres": "bash dev/postgres/10/start.sh",
245245
"start-mssql": "bash dev/mssql/2019/start.sh",
246246
"start-db2": "bash dev/db2/11.5/start.sh",
247-
"start-oracle": "bash dev/oracle/21-slim/start.sh",
247+
"start-oracle-oldest": "bash dev/oracle/18-slim/start.sh",
248+
"start-oracle-latest": "bash dev/oracle/21-slim/start.sh",
248249
"stop-mariadb": "bash dev/mariadb/10.3/stop.sh",
249250
"stop-mysql": "bash dev/mysql/5.7/stop.sh",
250251
"stop-mysql-8": "bash dev/mysql/8.0/stop.sh",
251252
"stop-postgres": "bash dev/postgres/10/stop.sh",
252253
"stop-mssql": "bash dev/mssql/2019/stop.sh",
253254
"stop-db2": "bash dev/db2/11.5/stop.sh",
254-
"stop-oracle": "bash dev/oracle/21-slim/stop.sh",
255+
"stop-oracle-oldest": "bash dev/oracle/18-slim/stop.sh",
256+
"stop-oracle-latest": "bash dev/oracle/21-slim/stop.sh",
255257
"restart-mariadb": "npm run start-mariadb",
256258
"restart-mysql": "npm run start-mysql",
257259
"restart-postgres": "npm run start-postgres",
258260
"restart-mssql": "npm run start-mssql",
259261
"restart-db2": "npm run start-db2",
260-
"restart-oracle": "npm run start-oracle",
262+
"restart-oracle-oldest": "npm run start-oracle-oldest",
263+
"restart-oracle-latest": "npm run start-oracle-latest",
261264
"----------------------------------------- local tests ---------------------------------------------": "",
262265
"test-unit-mariadb": "cross-env DIALECT=mariadb npm run test-unit",
263266
"test-unit-mysql": "cross-env DIALECT=mysql npm run test-unit",

src/dialects/oracle/connection-manager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const AbstractConnectionManager = require('../abstract/connection-manager');
66
const SequelizeErrors = require('../../errors');
77
const parserStore = require('../parserStore')('oracle');
88
const { logger } = require('../../utils/logger');
9+
const semver = require('semver');
910
const debug = logger.debugContext('connection:oracle');
1011
const DataTypes = require('../../data-types').oracle;
1112
const { promisify } = require('util');
@@ -132,6 +133,8 @@ export class OracleConnectionManager extends AbstractConnectionManager {
132133
}
133134

134135
const connection = await this.lib.getConnection(connectionConfig);
136+
// Setting the sequelize database version to Oracle DB server version to remove the roundtrip for DB version query
137+
this.sequelize.options.databaseVersion = semver.coerce(connection.oracleServerVersionString).version;
135138

136139
debug('connection acquired');
137140
connection.on('error', error => {

src/dialects/oracle/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ OracleDialect.prototype.supports = _.merge(_.cloneDeep(AbstractDialect.prototype
5454
GEOMETRY: false
5555
});
5656

57-
OracleDialect.prototype.defaultVersion = '18.4.0';
57+
OracleDialect.prototype.defaultVersion = '18.0.0';
5858
OracleDialect.prototype.Query = OracleQuery;
5959
OracleDialect.prototype.queryGenerator = OracleQueryGenerator;
6060
OracleDialect.prototype.DataTypes = DataTypes;

0 commit comments

Comments
 (0)