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

Feature Request: Lowercase dialect category inputs from user #2758

Closed
AstroGD opened this issue Aug 8, 2018 · 25 comments
Closed

Feature Request: Lowercase dialect category inputs from user #2758

AstroGD opened this issue Aug 8, 2018 · 25 comments

Comments

@AstroGD
Copy link

AstroGD commented Aug 8, 2018

Environment

Knex version: 0.15.2
Database + version: MySQL
OS: Linux Debian

Select applicable tempalate from below.
If issue is about oracledb support tag @ atiertant. For MSSql tag @ smorey2 .
Rest of dialects doesn't need tags.

Bug

If you try to install Knex on Linux Debian the following error occurres: Error: Cannot find module './dialects/MySQL/index.js'

This due to the fact, that paths are case-sensitive and the path must be /dialects/MySQL/index.js

I highly reccomend you to either change the path in code or rename the folder, as an installation of knex on debian is currently impossible without changing the folder manually.

@ricardograca
Copy link
Member

ricardograca commented Aug 8, 2018

I can install knex just fine on Ubuntu 16.04: npm install knex.

Can you share what steps you took to install knex that produce the error you mention?

@AstroGD
Copy link
Author

AstroGD commented Aug 10, 2018

I typed npm install knex and then run my program. My program then crashed with an unhandled promise rejection because the file was not found

@AstroGD
Copy link
Author

AstroGD commented Aug 10, 2018

Sorry i was a bit misleading there, the error does not occurr on installation but on running code using knex after the installation

@ricardograca
Copy link
Member

No idea how you're getting that error since that directory has a lowercase name on this repository and after installation. Can you either explain step by step how to reproduce this with a clean install or provide the necessary code to do so?

@AstroGD
Copy link
Author

AstroGD commented Aug 10, 2018

Another mistake from me: The Folder is named "mysql" and needs to be named "MySQL"

@AstroGD
Copy link
Author

AstroGD commented Aug 10, 2018

grafik
This is the error after a clean installation

@AstroGD
Copy link
Author

AstroGD commented Aug 10, 2018

Step by Step:

  • Go into an empty folder
  • type npm install knex
  • Wait till finished
  • put in any js file using knex
  • run the js file
  • get the error

@AstroGD
Copy link
Author

AstroGD commented Aug 10, 2018

Problem: When installing knex the folder is named "mysql" but it should be "MySQL"
Solution: Rename the folder to "MySQL" Path: node_modules/knex/lib/dialects

@ricardograca
Copy link
Member

I'm using knex on a project right now with MySQL and not seeing that error. Can you provide the "any js file using knex" that you're using?

@AstroGD
Copy link
Author

AstroGD commented Aug 10, 2018

Ill provide it asap

@tgriesser
Copy link
Member

The folder name is determined by whatever you provide as the config.client or config.dialect

https://github.com/tgriesser/knex/blob/2183a278268dc7aedf5edeccecb99176b9827f27/src/index.js#L29-L31

I'm guessing you have that as 'MySQL' instead of 'mysql', just fix that and it'll work.

@ricardograca
Copy link
Member

@tgriesser Maybe coerce whatever the user provides to lower case since all the dialect directories are in lower case anyway.

@AstroGD
Copy link
Author

AstroGD commented Aug 10, 2018

Ah now I see. Thats what I did wrong.
I suggest to LowerCase everything so that this mistake does not happen again to others

@AstroGD
Copy link
Author

AstroGD commented Aug 10, 2018

Thanks for your help

@ricardograca
Copy link
Member

I'm going to mark this as an enhancement since it's more about providing a better developer experience than an actual bug.

@AstroGD AstroGD changed the title Knex Error: Cannot find module './dialects/MySQL/index.js' when using linux [SOLUTION] Feature Request: Lowecase dialect categorie inputs from user Aug 10, 2018
@elhigu
Copy link
Member

elhigu commented Aug 18, 2018

Better to just throw an error about non-existing dialect than lowercasing automatically, which might cause still problems elsewhere.

@AstroGD AstroGD changed the title Feature Request: Lowecase dialect categorie inputs from user Feature Request: Lowercase dialect category inputs from user Aug 18, 2018
@AstroGD
Copy link
Author

AstroGD commented Aug 18, 2018

Or maybe both? Try lowercasing it and throw an error if the problem is still not solved?

@elhigu
Copy link
Member

elhigu commented Aug 18, 2018

Doing both is not any better than just lowercasing it. I would rather just force people to use correct parameter instead of trying to fix their input. IMO it would be also confusing that we are making some parts of knex caseinsensitive.

@ricardograca
Copy link
Member

@elhigu I disagree. I think that Knex should be more helpful in this case, since it already does that in other similar cases.

The thing is that there is nothing stating that the client is actually a directory name of something provided by Knex, so I think it's only natural that some people will try to use the typical product name (e.g. MySQL).

Also there's no list of the valid client names on the documentation, how are people supposed to know they need to use only a specific string out of a restricted list for these?

Finally, there are already some aliases so that it's possible to type client names that are not exactly the actual directory name (e.g. pg and postgresql for postgres). So, Knex is already not forcing people to use correct parameters, so why stop there and not be even more tolerant to client name variations?

@elhigu
Copy link
Member

elhigu commented Aug 20, 2018

Knex should be more helpful in this case, since it already does that in other similar cases

Does knex do that in other similar cases really (or maybe you were referring that alias list)? IMO having good error message and exception is more helpful that allowing case insensitive input in this case.

Also there's no list of the valid client names on the documentation

Yep. Valid names should be added to documentation.

Finally, there are already some aliases so that it's possible to type client names that are not exactly the actual directory name

I don't think that would has to be the directory name, but single correct name would have been nice to have in the first place. I have to agree that you have a point here :)

@kibertoad
Copy link
Collaborator

@elhigu I can create a PR that would validate the client param against constant set of known supported values and throw an explicit erro. Would that help?

@ricardograca
Copy link
Member

Does knex do that in other similar cases really (or maybe you were referring that alias list)?

Isn't it the same thing? You can call MySQL and alias of mysql if you prefer 😉 Same thing with dateTime -> datetime, bigIncrements -> bigincrements. Seems like there are already a few cases where knex is indeed case insensitive.

I agree that having a more explicit error message is the preferred solution though.

@elhigu
Copy link
Member

elhigu commented Aug 20, 2018

@kibertoad yep, I think that would be good solution. If you have spare time to add that, I'll gladly merge PR.

@kibertoad
Copy link
Collaborator

Sure, will work on it when I'm home.

elhigu pushed a commit that referenced this issue Aug 29, 2018
* Implement fail-fast logic for dialect resolution, clean-up code around.

* Remove method that was deprecated long time ago

* Address additional comments

* Try addressing comments

* Set client explicitly

* Fix compatibility with older Node versions
elhigu pushed a commit that referenced this issue Sep 26, 2018
* Kill queries after timeout for PostgreSQL

* Fix cancellation connection acquiring and test.

* Fix releasing connection in case query cancellation fails

* Add support for native enums on Postgres (#2632)

Reference https://www.postgresql.org/docs/current/static/sql-createtype.html

Closes #394

Signed-off-by: Will Soto <will.soto9@gmail.com>

* Removal of 'skim' (#2520)

* Allow overwriting log functions (#2625)

* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message

* Fixed onIn with empty values array (#2513)

* Drop support for strong-oracle (#2487)

* Remove babel-plugin-lodash (#2634)

While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.

* Add json support to the query builder for mysql (#2635)

* Add json support to the query builder for mysql

refs #1036

Based on #1902

* Clarify supported version

* fix wrapIdentifier not being called in postgres alter column (#2612)

* fix wrapIdentifier not being called in postgres alter column

* add test for wrapIdentifier call in postgres alter column

* add comment regarding issue

* add issue & PR #'s in comment

* Remove readable-stream and safe-buffer (#2640)

* Add json support to the query builder for mysql

refs #1036

Based on #1902

* Clarify supported version

* Use native Buffer and Stream implementations

* fixes 2630 (#2642)

* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)

* chore: add Node.js 10 (#2594)

* chore: add Node.js 10

* chore: trigger new build

* chore: update lockfile

* chore: trigger new build

* fix: use npm i instead of npm ci

* Fix mssql driver crashing (#2637)

* Run SQL Server tests locally running SQL server in docker

* WIP mssql test stuff

* Patched MSSQL driver to not crash knex anymore

* Removed semicolon from rollback stmt for oracle (#2564)

* Remove WebSQL dialect (#2647)

* Add json support to the query builder for mysql

refs #1036

Based on #1902

* Clarify supported version

* Use native Buffer and Stream implementations

* Remove WebSQL dialect

* add homepage field to package.json (#2650)

* Make the stream catch errors in the query (#2638)

* Make the stream catch errors in the query

* Fix another case in which stream doesnt emits error

* Linter stuff

* Remove setTimeout in tests

* Make a test not to check the MySQL error code

* Fix stream error catching for MariaDB and PostgreSQL

* Fix stream error catching in Oracle

* Throw the error after emitting it to the stream

* Throw the error without instantiating a new Error

* Various fixes to mssql dialect (#2653)

* Fixed float type of mssql to be float

* Many tests where postgres test was not actually ran at all

* Migrations to be mssql compatible

Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.

* Prevented mssql failing when invalid schema builder was executed by accident

Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started

* Fixed mssql trx rollback to always throw an error

Also modified some connection test query to be mssql compatible

* Fixed various bugs from MSSQL driver to make tests run

* Fixed mssql unique index to be compatible with other dialect implementations

* Enable running mssql tests on CI

* Test for #2588

* Updated tests to not be dependend on tables left from previous test rans

* Trying to make mssql server work on travis

* Updated changelog and version

* Drop mariadb support  (#2681)

* Dropped support for mariasql

* ESLint

* Fixed docs to build again

* Fix knex.initialize() and adds test (#2477)

* Fix knex.initialize() and adds test

* Fix knex.initialize() and adds test

* Added test for reinitializing pool after destroy

* Fixed destroy / reinitialization test

* Fixed the fix

* Implement missing schema support for mssql dialect

* chore: Update dependencies. Remove estraverse (#2691)

* Update dependencies. Remove estraverse

* Fix compatibility with new Sinon

* Increase mssql timeout

* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)

* Normalized and validated driverNames of test db clients and fixed oracle test setup

* Fixed failed queries from old query building tests which hadn't been ran in ages

* Allow selecting node version which is used to run oracledb docker tests

* Improved sql tester error messages

* Fixed rest of the oracledb tests

* Removed invalid flag from docker-compose

* Print mssql logs if initialization fails

* Fixed syntax error + final tests

* Added restart of failure for mssql DB initialization to try again if server was not ready

* Printout always mssql logs after container is started

* Fixed wait time printing after trying to connect

* Use npm run oracledb:test for testing oracle in travis

* Add Prettier (#2697)

* Add prettier
* Run files through prettier

* Istanbul -> NYC (#2700)

* istanbul -> nyc

* Update mocha

* Enforce code coverage (#2702)

* Enforce code coverage
* Update coverage numbers with current values

* version assignment on base class, copy on tx client, fix #2705

* Update changelog

* v0.15.1

* Added build step to test script. Fixes #2541 (#2712)

* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)

This reverts commit 90ed8db.

* Allow oracle failures for now

* Fix issue with select(0) (#2711)

* Fix issue with select(0). Fixes #2658

* Refactor migrator (#2695)

* Refactor migrator

* Fix exports

* Fix ESLint

* Fix migrator

* Fix reference to config

* Split some more

* Fix table builder

* Fix argument order

* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs

# Conflicts:
#	src/migrate/index.js
#	test/index.js
#	test/unit/migrate/migrator.js

* Fix #2715 (#2721)

* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision

* Bump changelog

* 0.15.2

* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)

* Add tests for multiple union arguments with callbacks and builders (#2749)

* Add tests for multiple union arguments

* Add some callback and raw tests to union unit tests

* Compile with before update so that bindings are put in correct order (#2733)

* Fix join using builder withSchema. (#2744)

* Use Datetime2 for MSSQL datetime + timestamp types (#2757)

* Use Datetime2 for MSSQL datetime + timestamp types

Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017

* Add tests for MSSQL datetime2 changes

* General/document breaking change (#2774)

* Add changelog entry for a breaking change

* Improve entry

* Allow timestamp with timezone on mssql databases (#2724)

* Allow timestamp with timezone on mssql databases

* Change timestamp parameter to use object instead of boolean

* Update dependencies (#2772)

* Feature/2690: Multiple migration directories (#2735)

* Implement support for multiple migration directories

* Add tests for new functionality

* Fix tape tests

* Pass migration directory upwards

* Fix multiple directory support

* Fix bugs

* Rollback correctly

* Fix remaining tests

* Address comments

* #2758: Implement fail-fast logic for dialect resolution (#2776)

* Implement fail-fast logic for dialect resolution, clean-up code around.

* Remove method that was deprecated long time ago

* Address additional comments

* Try addressing comments

* Set client explicitly

* Fix compatibility with older Node versions

* Use columnize instead of wrap in using(). (#2713)

* Use columnize instead of wrap in using().

This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.

* Exclude MSSQL from test as it does not support .using

* Change test to not use subquery

* Change test

* Introduced abstraction for getting migrations (#2775)

* Introduced abstraction for getting migrations

This would allow a webpack migration source which is compatible with bundling.

* Fixed migration validation with custom migration source

* Fixed issues after rebasing on muti directory PR

* Renamed parameter and fixed error message

* Addressed some PR comments

* Finished comment

* Moved filename extension filtering into fs-migrator

* Added test showing in memory custom migration source

* Cleaned up how to get config

* Fixed failing test

* Hopefully fix tests

* Fix Node.js 10 support in tests

* Test for correctly releasing cancel query connection
@kibertoad
Copy link
Collaborator

Probably this issue can be closed now?

@elhigu elhigu closed this as completed Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants