-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(oracle): add oracle dialect support (#14638)
* 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 !
- Loading branch information
1 parent
33d94b2
commit c230d80
Showing
79 changed files
with
3,677 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ esdoc | |
node_modules | ||
/lib | ||
/types | ||
.oracle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved | ||
|
||
services: | ||
oraclexedb: | ||
container_name: oraclexedb | ||
image: gvenzl/oracle-xe:21-slim | ||
environment: | ||
ORACLE_PASSWORD: password | ||
ports: | ||
- 1521:1521 | ||
healthcheck: | ||
test: ["CMD-SHELL", "sqlplus", "system/password@XEPDB1"] | ||
retries: 10 | ||
|
||
networks: | ||
default: | ||
name: sequelize-oraclexedb-network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved | ||
|
||
create user sequelizetest identified by sequelizepassword; | ||
grant connect to sequelizetest with admin option; | ||
grant create session to sequelizetest with admin option; | ||
grant grant any privilege to sequelizetest with admin option; | ||
grant grant any role to sequelizetest with admin option; | ||
grant create any table to sequelizetest with admin option; | ||
grant insert any table to sequelizetest with admin option; | ||
grant select any table to sequelizetest with admin option; | ||
grant update any table to sequelizetest with admin option; | ||
grant delete any table to sequelizetest with admin option; | ||
grant drop any table to sequelizetest with admin option; | ||
grant create view to sequelizetest with admin option; | ||
grant create user to sequelizetest with admin option; | ||
grant drop user to sequelizetest with admin option; | ||
grant create any trigger to sequelizetest with admin option; | ||
grant create any procedure to sequelizetest with admin option; | ||
grant create any sequence to sequelizetest with admin option; | ||
grant select any sequence to sequelizetest with admin option; | ||
grant drop any sequence to sequelizetest with admin option; | ||
grant create any synonym to sequelizetest with admin option; | ||
grant create any index to sequelizetest with admin option; | ||
grant alter user to sequelizetest with admin option; | ||
grant alter any table to sequelizetest with admin option; | ||
alter user sequelizetest quota unlimited on users; | ||
exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved | ||
|
||
#!/usr/bin/env bash | ||
set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | ||
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 | ||
|
||
# Remove an existing Oracle DB docker image | ||
docker-compose -p oraclexedb down --remove-orphans | ||
|
||
# Bring up new Oracle DB docker image | ||
docker-compose -p oraclexedb up -d | ||
|
||
# Wait until Oracle DB is set up and docker state is healthy | ||
./wait-until-healthy.sh oraclexedb | ||
|
||
# Moving privileges.sql to docker container | ||
docker cp privileges.sql oraclexedb:/opt/oracle/. | ||
|
||
# Granting all the needed privileges to sequelizetest user | ||
docker exec -t oraclexedb sqlplus system/password@XEPDB1 @privileges.sql | ||
|
||
SEQ_WORKSPACE="$PWD"/../../../ | ||
|
||
if [[ ! -d "$SEQ_WORKSPACE"/.oracle/ ]] | ||
then | ||
mkdir "$SEQ_WORKSPACE"/.oracle/ | ||
if [[ $(uname) == 'Linux' ]] | ||
then | ||
wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip --no-check-certificate && | ||
unzip instantclient-basic-linux.x64-21.6.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ && | ||
rm instantclient-basic-linux.x64-21.6.0.0.0dbru.zip && | ||
mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_6 "$SEQ_WORKSPACE"/.oracle/instantclient | ||
|
||
echo "Local Oracle instant client on Linux has been setup!" | ||
elif [[ $(uname) == 'Darwin' ]] | ||
then | ||
if [[ ! -d ~/Downloads/instantclient_19_8 ]] | ||
then | ||
curl -O https://download.oracle.com/otn_software/mac/instantclient/198000/instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && | ||
hdiutil mount instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && | ||
/Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru/install_ic.sh && | ||
hdiutil unmount /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru && | ||
rm instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && | ||
mv ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient | ||
else | ||
cp -rf ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient | ||
fi | ||
ln -s "$SEQ_WORKSPACE"/.oracle/instantclient/libclntsh.dylib "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release/ | ||
|
||
echo "Local Oracle instant client on macOS has been setup!" | ||
else | ||
# Windows | ||
curl -O https://download.oracle.com/otn_software/nt/instantclient/216000/instantclient-basic-windows.x64-21.6.0.0.0dbru.zip && | ||
unzip instantclient-basic-windows.x64-21.6.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ && | ||
rm instantclient-basic-windows.x64-21.6.0.0.0dbru.zip && | ||
mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_6/* "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release | ||
|
||
echo "Local Oracle instant client on $(uname) has been setup!" | ||
fi | ||
fi | ||
echo "Local Oracle DB is ready for use!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved | ||
|
||
#!/usr/bin/env bash | ||
set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | ||
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 | ||
|
||
|
||
docker-compose -p oraclexedb down --remove-orphans | ||
|
||
echo "Local Oracle DB instance stopped (if it was running)." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ "$#" -ne 1 ]; then | ||
>&2 echo "Please provide the container name or hash" | ||
exit 1 | ||
fi | ||
|
||
for _ in {1..50} | ||
do | ||
state=$(docker inspect -f '{{ .State.Health.Status }}' $1 2>&1) | ||
return_code=$? | ||
if [ ${return_code} -eq 0 ] && [ "$state" == "healthy" ]; then | ||
echo "$1 is healthy!" | ||
sleep 60 | ||
exit 0 | ||
fi | ||
sleep 6 | ||
done | ||
|
||
>&2 echo "Timeout of 5m exceeded when waiting for container to be healthy: $1" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.