-
Notifications
You must be signed in to change notification settings - Fork 350
Test for deeply nested through joins. #293
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
base: main
Are you sure you want to change the base?
Changes from all commits
842dc54
7783933
49d6c49
b2eb3a8
a454fa9
cc1ebb9
6acc9ec
81e1594
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,21 @@ | ||
| 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 { wrapOptions } from './wrap-options'; | ||
| 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 { wrapOptions, wrapOptionsV7 } from "./wrap-options"; | ||
|
|
||
| export function createSequelize6Instance(options?: Sequelize6Options): Sequelize6 { | ||
| export function createSequelize6Instance( | ||
| options?: Sequelize6Options | ||
| ): Sequelize6 { | ||
| return new Sequelize6(wrapOptions(options)); | ||
| } | ||
|
|
||
| export function createSequelize7Instance(options?: Sequelize7Options): Sequelize7 { | ||
| export function createSequelize7Instance( | ||
| options?: Sequelize7Options<any> | ||
|
Check failure on line 16 in dev/create-sequelize-instance.ts
|
||
| ): Sequelize7 { | ||
| // not compatible with node 10 | ||
| const { Sequelize: Sequelize7Constructor } = require('@sequelize/core'); | ||
| // @ts-expect-error -- wrapOptions expect sequelize 6. | ||
| return new Sequelize7Constructor(wrapOptions(options)); | ||
| const { Sequelize: Sequelize7Constructor } = require("@sequelize/core"); | ||
| return new Sequelize7Constructor(wrapOptionsV7(options)); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,15 +1,24 @@ | ||||||
| import defaults from 'lodash/defaults.js'; | ||||||
| import { CiDbConfigs } from './ci-db-configs'; | ||||||
| import { log } from './logging'; | ||||||
| import type { Dialect, Options } from 'sequelize'; | ||||||
| import defaults from "lodash/defaults.js"; | ||||||
| import { CiDbConfigs } from "./ci-db-configs"; | ||||||
| import { log } from "./logging"; | ||||||
| import type { | ||||||
| Dialect as Sequelize6Dialect, | ||||||
| Options as Sequelize6Options, | ||||||
| } from "sequelize"; | ||||||
| import type { | ||||||
| Options as Sequelize7Options, | ||||||
| Sequelize as Sequelize7, | ||||||
| } from "@sequelize/core"; | ||||||
|
|
||||||
| export function wrapOptions(options: Options = {}) { | ||||||
| export function wrapOptions(options: Sequelize6Options = {}) { | ||||||
| if (!process.env.DIALECT) { | ||||||
| throw new Error('Dialect is not defined! Aborting.'); | ||||||
| throw new Error("Dialect is not defined! Aborting."); | ||||||
| } | ||||||
|
|
||||||
| const isPostgresNative = process.env.DIALECT === 'postgres-native'; | ||||||
| const dialect = (isPostgresNative ? 'postgres' : process.env.DIALECT) as Dialect; | ||||||
| const isPostgresNative = process.env.DIALECT === "postgres-native"; | ||||||
| const dialect = ( | ||||||
| isPostgresNative ? "postgres" : process.env.DIALECT | ||||||
| ) as Sequelize6Dialect; | ||||||
|
|
||||||
| // 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 | ||||||
|
|
@@ -31,3 +40,35 @@ export function wrapOptions(options: Options = {}) { | |||||
|
|
||||||
| return options; | ||||||
| } | ||||||
|
|
||||||
| export function wrapOptionsV7(options: Partial<Sequelize7Options<any>> = {}) { | ||||||
| if (!process.env.DIALECT) { | ||||||
| throw new Error("Dialect is not defined! Aborting."); | ||||||
| } | ||||||
|
|
||||||
| const isPostgresNative = process.env.DIALECT === "postgres-native"; | ||||||
| const dialect = isPostgresNative ? "postgres" : process.env.DIALECT; | ||||||
|
|
||||||
| // Get the CI config for this dialect | ||||||
| const config = CiDbConfigs[dialect as keyof typeof CiDbConfigs] as any; | ||||||
|
||||||
| const config = CiDbConfigs[dialect as keyof typeof CiDbConfigs] as any; | |
| const config = CiDbConfigs[dialect as keyof typeof CiDbConfigs] as Partial<Sequelize7Options<any>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using 'any' as the generic type parameter reduces type safety. Consider using a more specific type or making it generic to preserve type information.