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

Incorrect casing for “ID” #1549

Open
toastal opened this issue Sep 4, 2024 · 5 comments
Open

Incorrect casing for “ID” #1549

toastal opened this issue Sep 4, 2024 · 5 comments

Comments

@toastal
Copy link

toastal commented Sep 4, 2024

All implicit generated IDs such as the ID for Foo is generated as FooId. While much of the documentation uses “ID”, the code representation is incorrect casing where “ID” is the standard abbreviation form for identifiers (IDs), not “Id”. Changing this would align other correctly-cased variables in the project like DB (along with uses of IO, UUID, & FromJSON from other libs), but still leaves incorrect cases like Sql instead of SQL for the initialism ‘structured query language’ (where documentation is largely using “SQL”).

What I would expect is the implicit ID for Foo becomes FooID… all fooId columns become fooID.

Moving from ‘ID’ to ‘Id’ is losing valuable casing information & if it weren’t important, we wouldn’t be bothering with upper case letters at all in English (& other languages with bicameral scripts).

@toastal
Copy link
Author

toastal commented Sep 4, 2024

I attempted to use something like

def :: ImplicitIdDef
def =
    autoIncrementingInteger
        { iidFieldType =
            \entName ->
                FTTypeCon Nothing $ unEntityNameHS entName `mappend` "ID"
        }

to no avail to fix the situation.

@toastal
Copy link
Author

toastal commented Sep 4, 2024

What I have not tried: sed -i "s/Id/ID/g" **/*.hs & seen if everything works.

@parsonsmatt
Copy link
Collaborator

Yeah, that assumption is baked into a lot of the TH code. I don't anticipate changing that to be easy or particularly flexible.

@toastal
Copy link
Author

toastal commented Sep 4, 2024

Is there a combinator route to go, or is Template Haskell the only/preferred way?

@parsonsmatt
Copy link
Collaborator

While you can define the PersistEntity stuff yourself, it's not really easy or well-supported.

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