Skip to content

Preserve upper-case when mapping SQL identifiers to Go identifiers #4202

@em-ily-dev

Description

@em-ily-dev

What do you want to change?

It would be great if sqlc could leave upper-case letters as upper-case when mapping SQL identifiers to Go identifiers.

The existing behavior works pretty well for all-lowercase SQL identifiers using underscores:

(SQL)          (Go)
request_id  => RequestID
http_id     => HttpID
artwork_key => ArtworkKey

But some databases use camel-case naming convention. Currently, sqlc changes upper-case letters to lower-case, producing:

(SQL)         (Go)
RequestID  => Requestid
HTTPID     => Httpid
ArtworkKey => Artworkkey

My proposal: leave upper-case letters as upper-case, and otherwise keep the existing behavior. This wouldn't affect anyone who uses all-lowercase SQL names, and it would produce nicer results for mixed-case SQL names:

(SQL)         (Go)
RequestID  => RequestID
HTTPID     => HTTPID
ArtworkKey => ArtworkKey

If this is acceptable, I'd be happy to submit a patch.

How does it sound?

What database engines need to be changed?

No response

What programming language backends need to be changed?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions