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
Knex imports sqlite in migrate:make when told to use pg #5102
Comments
Yep, I'm experiencing this too. The problem is that I don't think |
Until this is fixed, you can work around the issue by specifying your client on the command line, for example: |
An easier workaround is using 1.0.4 ;) |
@dstarke This does not help unfortunately, because the cli does not pick up the client option. |
It did for me, and I don't have sqlite installed in the project where I tried it. However, I agree that the real solution is to remove the referenced line of code. It looks like it is supposed to be enforcing a default value for the configuration, but what it is actually doing is creating a default command line argument value, and the command line argument values override the values specified in the configuration file. I'm happy to create a pull request that does that, but there are some additional complexities here that I'm not sure how to handle. It appears that the reason that line of code exists is that when you initialize knex, it will throw an error if no client is supplied. This makes sense for most other cases, but per the comment, for this particular command, we don't want to throw the error. If you want to preserve the behavior that this command can be run with no client configured, there needs to be an additional code path through initialization that skips throwing that error in this case. So there's a choice to be made between preserving the current expected behavior of the command, and making the setup code somewhat messier for this special case. |
Also had to rollback to Knex 1.0.4 just now. @matusekma, installing @vscode/sqlite3 package got past this first problem, but then another problem shows up where it complains about a sqlite3 option when creating a migration even though the client is specified as 'pg': |
This worked for me, thank you. I was banging my head against the problem for a couple of hours thinking my knexfile was wrong. |
thx god i found this issues.. it wasted me 2 hours already.. how come patch version introduce breaking changes? |
@OlivierCavadenti we need to hotfix this |
I will check this evening and dig into it. Is PR is enough to solve the problem ? #5106 |
@kibertoad / @OlivierCavadenti the regression is from the use of merge is not working in the way assumed by the usage and so the value from the second object is taking precedent over the first whereas the implementation implies the expectation that it is the other way round. |
Ok thanks for the analysis ! I will fix that this evening as soon as possible. |
@OlivierCavadenti I don't think this is correct. That merge causes the command line arguments to override the settings from the configuration file, which I think is what you want. The problem is that a default client is assigned early as a command line argument if none is supplied there, so it acts like a command line argument and overrides the configuration file value. |
Released in 1.0.6 |
Yep, I confirm that it worked. |
I'm still facing the same issue even though I've updated to 1.0.6 🤔 |
The problem is not fixed for me either. |
not fixed for me |
Fixed here : #5106 |
@dhensby Can you try 1.0.7? |
FYI - just removing this line fixed it locally for me Also, you have not pushed the tags into github for 1.0.6 or 1.0.7 I'll test 1.0.7 locally too |
1.0.7 appears to work locally for me now |
@dhensby Thank you, published tags and documentation now |
Environment
Knex version: 1.0.5
Database + version: Postgres 14
OS: macOS 12.3
Bug
knex migrate:make foo
wants (and fails) to load@vscode/sqlite3
even though the client is set topg
:Reduced test code
In an empty directory:
create
knexfile.js
:run:
Cause
This is caused by:
knex/bin/cli.js
Line 212 in f380e48
This fake client option which user never provided overrides whatever
client
is set in config.The upgrade guide (referenced here) says:
Note that it doesn't say that
@vscode/sqlite3
is now obligatory peer dependency when using migrations. This is a bug, there is no point in having@vscode/sqlite3
, it's not being imported for any reasonable purpose.The text was updated successfully, but these errors were encountered: