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

feat(sqlite): automatic path provision for 'options.storage' #11853

Merged
merged 6 commits into from Jan 22, 2020

Conversation

multum
Copy link
Contributor

@multum multum commented Jan 21, 2020

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Closes #11663

@multum multum requested a review from papb Jan 21, 2020
@codecov
Copy link

@codecov codecov bot commented Jan 21, 2020

Codecov Report

Merging #11853 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #11853   +/-   ##
=======================================
  Coverage   96.27%   96.27%           
=======================================
  Files          94       94           
  Lines        9209     9209           
=======================================
  Hits         8866     8866           
  Misses        343      343
Impacted Files Coverage Δ
lib/associations/belongs-to-many.js 98.07% <ø> (ø) ⬆️
lib/model.js 96.54% <100%> (ø) ⬆️
lib/dialects/mariadb/data-types.js 100% <100%> (ø) ⬆️
lib/dialects/postgres/data-types.js 96.26% <100%> (ø) ⬆️
lib/query-interface.js 92.19% <100%> (ø) ⬆️
lib/dialects/mysql/data-types.js 98.43% <100%> (ø) ⬆️
lib/dialects/abstract/query-generator.js 97.02% <100%> (ø) ⬆️
... and 1 more

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 53200c8...27dfeac. Read the comment docs.

Copy link
Member

@papb papb left a comment

Nice work, just a few refactor requests :)

lib/dialects/sqlite/connection-manager.js Outdated Show resolved Hide resolved
lib/dialects/sqlite/connection-manager.js Outdated Show resolved Hide resolved
test/integration/configuration.test.js Outdated Show resolved Hide resolved
@papb papb added dialect: sqlite status: awaiting response type: feature labels Jan 22, 2020
@papb papb changed the title fix(sqlite): added automatic path provision for 'options.storage' feat(sqlite): automatic path provision for 'options.storage' Jan 22, 2020
papb
papb approved these changes Jan 22, 2020
@papb
Copy link
Member

@papb papb commented Jan 22, 2020

Great work!

@papb papb added status: awaiting maintainer and removed status: awaiting response labels Jan 22, 2020
@papb papb merged commit cfc9685 into sequelize:master Jan 22, 2020
4 checks passed
@papb papb removed the status: awaiting maintainer label Jan 22, 2020
@@ -1,5 +1,7 @@
'use strict';

const path = require('path');
const jetpack = require('fs-jetpack');
Copy link
Contributor

@sushantdhiman sushantdhiman Jan 23, 2020

Choose a reason for hiding this comment

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

Do we really need to use this new library, its unpacked size is ~300KB

Copy link
Contributor Author

@multum multum Jan 23, 2020

Choose a reason for hiding this comment

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

@sushantdhiman You're right. This package greatly simplifies the work with the file system, makes the code more concise. In addition, sequelize included it as devDependency. But I did not pay attention to its size. This in my opinion is not critical on the server side, but due to the fact that the file system is used by the sequelize only in ~ one place, I would like to do the following:

  1. Return the fs-jetpack package back to devDependencies and use it only for the convenience of writing tests
  2. Write my own function(similar to jetpack.dir()) to automatically provide the path for sqlite.options.storage

Copy link
Contributor

@sushantdhiman sushantdhiman Jan 23, 2020

Choose a reason for hiding this comment

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

It is only used for creating a path jetpack.dir(path.dirname(options.storage)), right? With Node 10 mkdirSync supports this https://nodejs.org/docs/latest-v10.x/api/fs.html#fs_fs_mkdirsync_path_options

Copy link
Contributor Author

@multum multum Jan 23, 2020

Choose a reason for hiding this comment

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

Awesome! Since sequelize 6.x will support node version 10 and more, we can actually use fs.mkdir(path, { recursive: true }). Can I do a pull request?

Copy link
Contributor

@sushantdhiman sushantdhiman Jan 23, 2020

Choose a reason for hiding this comment

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

That will be great @multum

Copy link
Member

@papb papb Jan 23, 2020

Choose a reason for hiding this comment

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

Oops, nice catch @sushantdhiman, sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialect: sqlite type: feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants