Open GetPsyched opened 3 weeks ago
This exact feature is being worked on right now: https://github.com/drizzle-team/drizzle-orm/discussions/2834
At first glance that did seem like it directly fixes my issue, but not really.
The discussion is primarily talking about taking the camelCase column names defined in TS and convert them to snake_case for running any SQL queries. What I want is the exact opposite. When running db.execute
, I want the output object to have the keys in camelCase instead of whatever case exists in the schema.
This definitely can be an extension of that discussion but as of writing, I don't see anything mentioned confirming that the opposite will also be supported.
The discussion is primarily talking about taking the camelCase column names defined in TS and convert them to snake_case for running any SQL queries. What I want is the exact opposite. When running
db.execute
, I want the output object to have the keys in camelCase instead of whatever case exists in the schema.
Oh, what you're talking about will also be supported soon, so both camelCase to snake_case and the opposite will be supported soon. This isn't mentioned in the discussion so I should've been more clear about that.
Oh okay; was that discussed privately somewhere?
Oh okay; was that discussed privately somewhere?
Yes, in an internal discussion with advocates and team members.
Describe what you want
EDIT: The casing can be fetched from the global config, as described in #2834, instead of having some arbitrary method for it.
When using
db.execute
, the fields remain the same case as they are in the DB; this is totally valid and acceptable. However, it would be neat to have a method on it ($toCamelCase
) that converts all the fields to camelCase.For example, running this method:
currently outputs
{ foo_bar: 'some-value' }
, but with something like$toCamelCase
,it would output
{ fooBar: 'some-value' }
.Currently I do this manually; I wonder if the team would consider this since it's kind of subjective. Feel free to close if this is not planned.