Skip to content

Fix constructor to support all Sequelize options#120

Merged
RobinBuschmann merged 1 commit into
sequelize:masterfrom
suttna:fix-constructor
Aug 31, 2017
Merged

Fix constructor to support all Sequelize options#120
RobinBuschmann merged 1 commit into
sequelize:masterfrom
suttna:fix-constructor

Conversation

@bilby91

@bilby91 bilby91 commented Aug 31, 2017

Copy link
Copy Markdown
Contributor

Fixes #119

@codecov-io

codecov-io commented Aug 31, 2017

Copy link
Copy Markdown

Codecov Report

Merging #120 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
+ Coverage   96.48%   96.49%   +<.01%     
==========================================
  Files          99       99              
  Lines         911      912       +1     
  Branches      121      122       +1     
==========================================
+ Hits          879      880       +1     
  Misses         11       11              
  Partials       21       21
Impacted Files Coverage Δ
lib/models/v3/Sequelize.ts 98.18% <100%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27efc23...1de8ae4. Read the comment docs.

@bilby91

bilby91 commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

@RobinBuschmann Hey, what do you think ? I think this is the last issue that is blocking us to get this in production! A beta.2 today would be AWESOME!

Comment thread test/utils/sequelize.ts Outdated
export function createSequelizeValidationOnly(useModelsInPath: boolean = true): Sequelize {

return new Sequelize({
dialect: 'sqlite',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bilby91 Whats the purpose of adding the dialectoption here?

@bilby91

bilby91 commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

I'm not sure why it was working before. v4 requires a dialect to be explicitly defined.

@RobinBuschmann

Copy link
Copy Markdown
Member

Strange, there seem to have happened an issue earlier caused by another pull request I think.

There is a ISequelizeValidationOnlyConfig which is missing in:

export type SequelizeConfig = ISequelizeConfig | ISequelizeUriConfig | ISequelizeDbNameConfig;

When you add ISequelizeValidationOnlyConfig to SequelizeConfig it should work without dialect: 'sqlite'.

@bilby91

bilby91 commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

@RobinBuschmann Want me to add it ?

@RobinBuschmann

RobinBuschmann commented Aug 31, 2017

Copy link
Copy Markdown
Member

It depends... does it build without dialect: 'sqlite',? Cause this line does not fit the actual api, because it is validationOnly without the need to specify database configuration.

If it is building, then we should create another pull request for this issue.

@bilby91

bilby91 commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

@RobinBuschmann Changing this export type SequelizeConfig = ISequelizeConfig | ISequelizeUriConfig | ISequelizeDbNameConfig | ISequelizeValidationOnlyConfig; didn't fix the issue. I think the problem is different. The thing is that now the url constructor passes the options always and in v4 you need to always define the dialect. Make sense ?

@bilby91

bilby91 commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

If we remove the dialect: 'sqlite' tests won't pass. And I think it makes sense that they don't pass without that option.

@RobinBuschmann

Copy link
Copy Markdown
Member

When validationOnly: true is defined, these options (e.g. dialect) will be added automatically: https://github.com/RobinBuschmann/sequelize-typescript/blob/master/lib/models/BaseSequelize.ts#L61

@RobinBuschmann

Copy link
Copy Markdown
Member

validationOnly: true makes it possible to use sequelize-typescript without connecting to any database. Thats why it should not be necessary to define database options.

@RobinBuschmann

Copy link
Copy Markdown
Member

Here the reason why it compiles with validationOnly: true and without dialect: https://github.com/RobinBuschmann/sequelize-typescript/blob/master/lib/models/Sequelize.d.ts#L11

@bilby91

bilby91 commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

@RobinBuschmann Good. Got it. It was not working localy because I though npm run test was compiling the code :(.

Now it should be good to go

@RobinBuschmann
RobinBuschmann merged commit 4050995 into sequelize:master Aug 31, 2017
@bilby91
bilby91 deleted the fix-constructor branch August 31, 2017 20:37
@bilby91

bilby91 commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for the awesome feedback loop @RobinBuschmann . Can we get a beta.2 🎉 ?

@RobinBuschmann

Copy link
Copy Markdown
Member

Thank you for fixing this :)

Its done sequelize-typescript@0.5.0-beta.2 🎉

@bilby91

bilby91 commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

@RobinBuschmann Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants