-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Configuration option to allow override/hook to identifier wrapping code #2217
Configuration option to allow override/hook to identifier wrapping code #2217
Conversation
By "first part", are you referring to the transformation of identifiers with no concept of direction? The code appears to always convert to snake_case, instead of conditionally to that or camelCase. |
@stevenvachon by the "first part" I mean converting identifiers and with "second part" I mean converting column names of the result rows read from database. Did you check the documentation pull request, which explains what the method does? If you have suggestions how to improve that all the comments are appreciated. Also there is no hard coded |
The documentation is in a script file which doesn't make for the clearest to comprehension. As for the snake_case -> camelCase, I was referring to the test file (which instead concatenates). |
Yes. That is very much intentional. It just tests that modifying and calling original wrapped callback actually works. |
@wubzz @rhys-vdw @tgriesser @koistya any comments on this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice simple solution to something that has been requested for a long time. I have no objections!
I'll still check if I'm able to add info, which part of the identifier is being transformed. Somewhat the same way that @koistya mentioned in issue #2084. EDIT: I'm pretty sure that there is no robust way to this. For example with |
Is there an estimated timeline for when a pull request will be made to the main knex repo for the last half of this feature? In other words, when will the full implementation be available for use? |
@sdwrage do you mean when this one is released or if there is going to be also hook for modifying column names read from database? Anyway, both features will be released in next release knex 0.14.0 hopefully next month. There are some other PRs still which I would like to get merged before it. |
@elhigu both and thank you for the answer :) |
First part of #2084 and #929 feature, which allows to write custom identifier wrapper methods.
So effectively you can describe function how each identifier name are treated, like for example id replacement in
knex.raw('??', ['MyTable.myCol'])
will behave. This is pretty nice feature for ORMs which would like to allow for example different naming scheme for database tables/columns and on javascript side.Documentation PR is here knex/documentation#51