Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/method binding on knex proxy (#3717)
* knex methods are proxies for context methods ... ... as opposed to injecting the methods directly onto the knex function. (Which was then causing `this` to point to the wrong object when evaluating the context methods) * Moved CONTEXT_METHODS constant to a higher scope * mv knex.context -> this.context * Extracted KNEX_PROPERTY_DEFINITIONS to module scope ... ... which was possible since all of the properties reference `this` instead of `knex` now * shallowCloneFunction no longer accesses _context ... ... instead, it uses the normal context property * transaction method delegates to _transaction ... ... This way, we can be sure that the lower-level details are consistent across implementations. Individual implementations just need to handle the quirks around setting up the `config` and `outerTx` * CONTEXT_METHODS shared. Fixed override of withUserParams ... Restructured the code so that CONTEXT_METHODS populates the KNEX_PROPERTY_DEFINITIONS with the proxy methods. In doing so, it also exposed the fact that the withUserParams(..) method was being overridden on the Transactor instead of its context. So, that bug was fixed as well. * Added a TODO to remove client.makeKnex(..) in future PR * Added a warning about QueryBuilder.extend(..) and side-effects
- Loading branch information
1 parent
acf56b5
commit 37d9c30
Showing
3 changed files
with
132 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters