Skip to content

Couldn't find option to disable upppercase ID for every _id field #2161

Closed

Description

@priyanshujain

I can see that sqlc create ID for every _id field suffix. Is there any parameter so that it generated capitalized Id instead of uppercase ID suffix.

For ex. currently it does

app_id      -> AppID

I want to do

app_id      -> AppId

@kyleconroy Please help here.

Activity

  1. priyanshujain commented on Mar 20, 2023

    @priyanshujain
    Author

    As I can see here, There is intentional modification of id to ID. Can you please help me understand the reason behind it? Thanks!

  2. sergey-tb commented on Mar 26, 2023

    @sergey-tb

    @priyanshujain , it is because of this silly naming convention rule in Go.

    In reality people rarely follow it, due to KpmgWsUrl is easier to read than KPMGWSURL. However, sqlc also doesn't follow all acronyms, except for some reasons for ID. You may try this setting, but it seems not a wildcard so you will need to do it for all IDs.

  3. priyanshujain commented on Mar 26, 2023

    @priyanshujain
    Author

    @sergey-tb Thanks. If I use renaming settings conf then it's a never-ending amount of work.

    Is it worth building a feature skipping initialisms for sqlc? As It says in go wiki

    The code generated by the protocol buffer compiler is exempt from this rule. Human-written code is held to a higher standard than machine-written code.
    
    

    And as go devs say - There's a never-ending list, we'll get it wrong, and it's simpler to stick with the current mechanical translation. (link)

    Please let me know your thoughts. cc: @kyleconroy

  4. sergey-tb commented on Mar 26, 2023

    @sergey-tb

    @priyanshujain , I'm not a contributor of sqlc, but for sure agree initialism should be configured. I like how some linters do it, eg: initialism : ["id","url"]

  5. added this to the 1.27.0 milestone on Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions