prisma-engines icon indicating copy to clipboard operation
prisma-engines copied to clipboard

fix(fmt): use camel case for new fields

Open emi0x7d1 opened this issue 1 year ago • 8 comments

Make the formatter add missing fields in camelCase instead of using the model's name.

Sorry for the poor pull request but I cannot build this nor run the tests. Hopefully it's as simple as this or someone better than me can take it over.

https://github.com/prisma/language-tools/issues/793 https://github.com/prisma/language-tools/issues/713

emi0x7d1 avatar Aug 18 '23 04:08 emi0x7d1

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 18 '23 04:08 CLAassistant

CodSpeed Performance Report

Merging #4150 will not alter performance

Comparing emi0x7d1:fmt-camelcase (b3dd784) with main (1071f46)

Summary

✅ 11 untouched benchmarks

codspeed-hq[bot] avatar Aug 21 '23 13:08 codspeed-hq[bot]

May I ask why not? Using pascal case for the generated fields is strange. Most people will end up changing the name.

I guess either following the normal convention (camel case) or generating a hole that produces a syntax error would be better so that users know a field was generated and a bad named field doesn't slip through.

emi0x7d1 avatar Aug 21 '23 16:08 emi0x7d1

I don't think it uses pascal case, it just uses the unmodified casing of the model name that is being referenced.

janpio avatar Aug 21 '23 22:08 janpio

I don't think it uses pascal case, it just uses the unmodified casing of the model name that is being referenced.

Yep, but since that's the naming convention most projects use, the generated field ends up looking weird.

emi0x7d1 avatar Aug 22 '23 06:08 emi0x7d1

Will this question be followed up? I'm tired of manually modifying the generated field names every time.

51750 avatar Jul 12 '24 02:07 51750

Hey folks, just so y'all know: as part of the 5.17 release, we've added quick-fixes that handle adding missing fields / relations with the behaviour that you're looking for in this PR.

PR: https://github.com/prisma/prisma-engines/pull/4953

Druue avatar Jul 18 '24 15:07 Druue

@Druue

…as part of the 5.17 release, we've added quick-fixes that handle adding missing fields / relations with the behaviour that you're looking for in this PR.

I don't see that being the case nor do the test cases in https://github.com/prisma/prisma-engines/pull/4953 look like they handle the case.

I just tested it with v5.20.0 and I still get Invite Invite[] instead of invites Invite[] when the VS Code Extension adds the relation for me.

There is still this annoying mismatch between what the Docs suggests as best practice https://www.prisma.io/docs/orm/prisma-schema/data-model/relations#relation-fields posts Post[] and what the extension does Post Post[]. See https://github.com/prisma/language-tools/issues/713#issuecomment-785585859 for more.

tordans avatar Sep 25 '24 09:09 tordans