Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for changes in v7 #284

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: /bin/bash ./dev/prepare-ci.sh
- name: Execute SSCCE
run: yarn run _test
Expand All @@ -45,7 +44,6 @@ jobs:
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: /bin/bash ./dev/prepare-ci.sh
- run: yarn start-postgres-${{ matrix.postgres-version }}
- name: Execute SSCCE
Expand All @@ -66,7 +64,6 @@ jobs:
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: /bin/bash ./dev/prepare-ci.sh
- run: yarn start-${{ matrix.dialect }}-${{ matrix.database-version }}
- name: Execute SSCCE
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test.sqlite2
*.sublime*
package-lock.json
pnpm-lock.yaml
yarn.lock

.nyc_output
coverage-*
Expand Down
70 changes: 70 additions & 0 deletions dev/ci-db-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,73 @@ export const CiDbConfigs = {
minifyAliases: Boolean(env.SEQ_PG_MINIFY_ALIASES),
},
};

export const CiDbConfigsV7 = {
mssql: {
server: env.SEQ_MSSQL_HOST || env.SEQ_HOST || 'localhost',
authentication: {
type: 'default',
options: {
userName: env.SEQ_MSSQL_USER || env.SEQ_USER || 'SA',
password: env.SEQ_MSSQL_PW || env.SEQ_PW || 'Password12!',
},
},
port: env.SEQ_MSSQL_PORT || env.SEQ_PORT || 22_019,
database: env.SEQ_MSSQL_DB || env.SEQ_DB || 'sequelize_test',
encrypt: false,
requestTimeout: 25_000,
pool: {
max: Number(env.SEQ_MSSQL_POOL_MAX || env.SEQ_POOL_MAX || 5),
idle: Number(env.SEQ_MSSQL_POOL_IDLE || env.SEQ_POOL_IDLE || 3000),
},
},

mysql: {
database: env.SEQ_MYSQL_DB || env.SEQ_DB || 'sequelize_test',
user: env.SEQ_MYSQL_USER || env.SEQ_USER || 'sequelize_test',
password: env.SEQ_MYSQL_PW || env.SEQ_PW || 'sequelize_test',
host: env.MYSQL_PORT_3306_TCP_ADDR || env.SEQ_MYSQL_HOST || env.SEQ_HOST || '127.0.0.1',
port: env.MYSQL_PORT_3306_TCP_PORT || env.SEQ_MYSQL_PORT || env.SEQ_PORT || 20_057,
pool: {
max: Number(env.SEQ_MYSQL_POOL_MAX || env.SEQ_POOL_MAX || 5),
idle: Number(env.SEQ_MYSQL_POOL_IDLE || env.SEQ_POOL_IDLE || 3000),
},
},

snowflake: {
username: env.SEQ_SNOWFLAKE_USER || env.SEQ_USER || 'root',
password: env.SEQ_SNOWFLAKE_PW || env.SEQ_PW || '',
database: env.SEQ_SNOWFLAKE_DB || env.SEQ_DB || 'sequelize_test',
account: env.SEQ_SNOWFLAKE_ACCOUNT || env.SEQ_ACCOUNT || 'sequelize_test',
role: env.SEQ_SNOWFLAKE_ROLE || env.SEQ_ROLE || 'role',
warehouse: env.SEQ_SNOWFLAKE_WH || env.SEQ_WH || 'warehouse',
schema: env.SEQ_SNOWFLAKE_SCHEMA || env.SEQ_SCHEMA || '',
},

mariadb: {
database: env.SEQ_MARIADB_DB || env.SEQ_DB || 'sequelize_test',
user: env.SEQ_MARIADB_USER || env.SEQ_USER || 'sequelize_test',
password: env.SEQ_MARIADB_PW || env.SEQ_PW || 'sequelize_test',
host: env.MARIADB_PORT_3306_TCP_ADDR || env.SEQ_MARIADB_HOST || env.SEQ_HOST || '127.0.0.1',
port: env.MARIADB_PORT_3306_TCP_PORT || env.SEQ_MARIADB_PORT || env.SEQ_PORT || 21_103,
pool: {
max: Number(env.SEQ_MARIADB_POOL_MAX || env.SEQ_POOL_MAX || 5),
idle: Number(env.SEQ_MARIADB_POOL_IDLE || env.SEQ_POOL_IDLE || 3000),
},
},

sqlite: {},

postgres: {
database: env.SEQ_PG_DB || env.SEQ_DB || 'sequelize_test',
user: env.SEQ_PG_USER || env.SEQ_USER || 'sequelize_test',
password: env.SEQ_PG_PW || env.SEQ_PW || 'sequelize_test',
host: env.POSTGRES_PORT_5432_TCP_ADDR || env.SEQ_PG_HOST || env.SEQ_HOST || '127.0.0.1',
port: env.POSTGRES_PORT_5432_TCP_PORT || env.SEQ_PG_PORT || env.SEQ_PORT || 23_010,
pool: {
max: Number(env.SEQ_PG_POOL_MAX || env.SEQ_POOL_MAX || 5),
idle: Number(env.SEQ_PG_POOL_IDLE || env.SEQ_POOL_IDLE || 3000),
},
minifyAliases: Boolean(env.SEQ_PG_MINIFY_ALIASES),
},
};
6 changes: 3 additions & 3 deletions dev/create-sequelize-instance.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { Options as Sequelize6Options } from 'sequelize';
import { Sequelize as Sequelize6 } from 'sequelize';
import type { Options as Sequelize7Options, Sequelize as Sequelize7 } from '@sequelize/core';
import type { Options as Sequelize7Options, Sequelize as Sequelize7, AbstractDialect } from '@sequelize/core';
import { wrapOptions } from './wrap-options';

export function createSequelize6Instance(options?: Sequelize6Options): Sequelize6 {
return new Sequelize6(wrapOptions(options));
}

export function createSequelize7Instance(options?: Sequelize7Options): Sequelize7 {
export function createSequelize7Instance(options?: Omit<Sequelize7Options<AbstractDialect<object, object>>, "dialect">): Sequelize7 {
// not compatible with node 10
const { Sequelize: Sequelize7Constructor } = require('@sequelize/core');
// @ts-expect-error -- wrapOptions expect sequelize 6.
return new Sequelize7Constructor(wrapOptions(options));
return new Sequelize7Constructor(wrapOptions(options, true));
}
2 changes: 1 addition & 1 deletion dev/mssql/latest/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
volumes:
- mssql-latest:/var/opt/mssql
healthcheck:
test: ["CMD", "/opt/mssql-tools/bin/sqlcmd", "-S", "localhost", "-U", "SA", "-P", "Password12!", "-l", "30", "-Q", "SELECT 1"]
test: ["CMD", "/opt/mssql-tools18/bin/sqlcmd", "-S", "localhost", "-No", "-U", "SA", "-P", "Password12!", "-l", "30", "-Q", "SELECT 1"]
interval: 3s
timeout: 1s
retries: 10
Expand Down
2 changes: 1 addition & 1 deletion dev/mssql/latest/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ docker compose -p sequelize-mssql-latest up -d
./../../wait-until-healthy.sh sequelize-mssql-latest

docker exec sequelize-mssql-latest \
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -Q "CREATE DATABASE sequelize_test; ALTER DATABASE sequelize_test SET READ_COMMITTED_SNAPSHOT ON;"
/opt/mssql-tools18/bin/sqlcmd -S localhost -No -U SA -P "Password12!" -Q "CREATE DATABASE sequelize_test; ALTER DATABASE sequelize_test SET READ_COMMITTED_SNAPSHOT ON;"

DIALECT=mssql ts-node ../../check-connection.ts
12 changes: 6 additions & 6 deletions dev/prepare-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
yarn install --ignore-engines;

if [ "$DIALECT" = "postgres" ]; then
yarn add pg@^8 pg-hstore@^2 pg-types@^2 --ignore-engines;
yarn add pg@^8 pg-hstore@^2 pg-types@^2 @sequelize/postgres --ignore-engines;
elif [ "$DIALECT" = "postgres-native" ]; then
yarn add pg@^8 pg-hstore@^2 pg-types@^2 pg-native --ignore-engines;
yarn add pg@^8 pg-hstore@^2 pg-types@^2 pg-native @sequelize/postgres --ignore-engines;
elif [ "$DIALECT" = "mysql" ]; then
yarn add mysql2@^2 --ignore-engines;
yarn add mysql2@^2 @sequelize/mysql --ignore-engines;
elif [ "$DIALECT" = "mariadb" ]; then
yarn add mariadb@^2 --ignore-engines;
yarn add mariadb@^2 @sequelize/mariadb --ignore-engines;
elif [ "$DIALECT" = "sqlite" ]; then
yarn add sqlite3@^5 --ignore-engines;
yarn add sqlite3@^5 @sequelize/sqlite3 --ignore-engines;
elif [ "$DIALECT" = "mssql" ]; then
yarn add tedious@^8 --ignore-engines;
yarn add tedious@^8 @sequelize/mssql --ignore-engines;
fi
9 changes: 3 additions & 6 deletions dev/wrap-options.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import defaults from 'lodash/defaults.js';
import { CiDbConfigs } from './ci-db-configs';
import { CiDbConfigs, CiDbConfigsV7 } from './ci-db-configs';
import { log } from './logging';
import type { Dialect, Options } from 'sequelize';

export function wrapOptions(options: Options = {}) {
export function wrapOptions(options: Options = {}, v7 = false) {
if (!process.env.DIALECT) {
throw new Error('Dialect is not defined! Aborting.');
}
Expand All @@ -14,7 +14,7 @@ export function wrapOptions(options: Options = {}) {
// this fails in the CI due to mismatch between Sequelize 6 & 7. Should be resolved once we drop Sequelize 6.
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore
const config = CiDbConfigs[dialect];
const config = v7 ? CiDbConfigsV7[dialect] : CiDbConfigs[dialect];

options.dialect = dialect;
if (isPostgresNative) {
Expand All @@ -26,8 +26,5 @@ export function wrapOptions(options: Options = {}) {
...config,
});

// @ts-expect-error
options.__isOptionsObject__ = true;

return options;
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"cross-env": "^7",
"fs-jetpack": "^4",
"sequelize": "^6",
"@sequelize/core": "alpha",
"sinon": "^13",
"@sequelize/core": "latest",
"sinon": "^10",
"sinon-chai": "^3"
},
"scripts": {
Expand Down Expand Up @@ -69,6 +69,7 @@
"typescript": "~4.5"
},
"resolutions": {
"chai-datetime/chai": "^4"
"chai-datetime/chai": "^4",
"nise": "5.0.1"
}
}
26 changes: 13 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,75 +52,75 @@ You'll need to install the `pg` package and have a postgres database running.

```shell
# Do this only once.
npm install pg
npm install pg @sequelize/postgres
# or
npm install pg-native
npm install pg-native @sequelize/postgres

# if you need to use DataTypes.HSTORE, you also need this dependency
npm install pg-hstore

# Start the postgres database using docker.
# Requires docker. You can also run your own database if you prefer.
npm run start:postgres
npm run start-postgres-latest

# run the sscce!
npm run test:postgres
# or
npm run test:postgres-native

# Remember to stop the docker container once you're done.
npm run stop:postgres
npm run stop-postgres
```

#### mariadb

```shell
# Do this only once.
npm install mariadb
npm install mariadb @sequelize/mariadb

# Start the mariadb database using docker.
# Requires docker. You can also run your own database if you prefer.
npm run start:mariadb
npm run start-mariadb

# run the sscce!
npm run test:mariadb

# Remember to stop the docker container once you're done.
npm run stop:mariadb
npm run stop-mariadb
```

#### mysql

```shell
# Do this only once.
npm install mysql2
npm install mysql2 @sequelize/mysql

# Start the mysql database using docker.
# Requires docker. You can also run your own database if you prefer.
npm run start:mysql
npm run start-mysql-latest

# run the sscce!
npm run test:mysql

# Remember to stop the docker container once you're done.
npm run stop:mysql
npm run stop-mysql
```

#### mssql (SQL Server)

```shell
# Do this only once.
npm install tedious
npm install tedious @sequelize/mssql

# Start the mssql database using docker.
# Requires docker. You can also run your own database if you prefer.
npm run start:mssql
npm run start-mssql-latest

# run the sscce!
npm run test:mssql

# Remember to stop the docker container once you're done.
npm run stop:mssql
npm run stop-mssql
```

### Step 3 - Commit your SSCCE & sent it to us
Expand Down
Loading