knex: Allow to customize how identifiers must be wrapped
This would unlock scenarios such as automatically converting camelCase to snake_case and vise verse. See https://medium.com/p/956357872fe4
It could look something like this (db.js):
import knex from 'knex'
function wrapIdentifier(type, value) {
if (type === 'as') return ....;
if (type === 'select') return ....;
return ...;
}
export default knex({
client: 'pg',
connection: process.env.DATABASE_URL,
wrapIdentifier,
});
Please vote up if you’re planning to use this feature, or vote down if you think it shouldn’t be in the library.
Ref #929
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 14
- Comments: 15 (7 by maintainers)
before christmas, maybe this month, maybe next
@kanekotic Those wrapper cannot distinguish if the identifier is table name or column name. So you cannot do that only for table names. However if you want to have all identifiers, without quotes that is completely possible.
Just do something like this (https://knexjs.org/#Installation-wrap-identifier)
This will be released in knex 0.14
Or perhaps just a
transformfunction. My code currently looks rather unpleasant having to do this manually.This would be nice:
or