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]: Camel case plugin - option to disable transformations on selected columns or data types #961

Open
snax4a opened this issue Apr 23, 2024 · 1 comment

Comments

@snax4a
Copy link

snax4a commented Apr 23, 2024

Hello,

The CamelCasePlugin options allow disabling conversion to camel case on all nested objects https://kysely-org.github.io/kysely-apidoc/interfaces/CamelCasePluginOptions.html#maintainNestedObjectKeys, however i don't find this quite useful as for example we might want to keep conversion on nested objects e.q. included by jsonArrayFrom, jsonObjectFrom helpers but we might not want to convert some jsonb column data.

For example we could have a custom_fields jsonb column where object keys are actual values (in this case, related entity ids)

{
   "field_9npl6g7wqazcdgjz":{
      "name":"Name 1",
      "type":"TYPE_1",
   },
   "field_mvj5nwggpmyxwbj6":{
      "name":"Name 2",
      "type":"TYPE_2"
   }
}

I would want to be able to disable conversion for this selected column or data type e.q. jsonb either on the pluguin level, or ideally on the query level if it would be possible.

new CamelCasePlugin({ skipDataTypes: ["json", "jsonb"] })
// or
new CamelCasePlugin({ skipColumns: ["customFields"] })
db.selectFrom("Table")
  .select(["col1", "col2"])
  .skipCamelCase(["col2"])
  .executeTakeFirst();
@koskimas
Copy link
Member

Kysely doesn't know about data types. We don't know something's json or jsonb. Skipping by column name would be possible, but only if you don't alias the column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants