-
Notifications
You must be signed in to change notification settings - Fork 13
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
edgeql-go generates private only code #245
Comments
Thanks for the feedback @joeyak! The generator intentionally doesn't change the case of properties/links in query shapes. EdgeDB is unopinionated about casing style since it can be used with clients of any language. If we alter the case in a query then it is possible for the altered names to collide with other names. For example you could have two properties Because there are no constraints on property or link names you can define your schema or your query with upper case names. You could write your example query like this: SELECT Auth {
ID := .id,
AccessToken := .access_token,
RefreshToken := .refresh_token,
TokenExpires := .token_expires
}
FILTER .user.channel_settings.enabled = true; We are open to adding an opt-in flag that would enable a snake to pascal case transformation on the result type. I'll use this issue for adding this feature. We just don't want to make it the default behavior. |
That sounds like a great idea. I've been trying to play around to figure out how to expose those (didn't think to capitalize the results like that), but I've already gotten the hang of exposing the private fields. Thanks for the help, I'll definitely update my queries! |
The new `-mixedcaps` option changes snake_case names in shapes to MixedCaps names in go structs. ``` select User { first_name, last_name, } ``` Becomes: ```go type MyQueryResult struct { FirstName string `edgedb:"first_name"` LastName string `edgedb:"last_name"` } ``` Without this option enabled names are used exactly as they appear in shapes. For example the query above would produce the following struct: ```go type MyQueryResult struct { first_name string `edgedb:"first_name"` last_name string `edgedb:"last_name"` } ``` working on #245
The new `-mixedcaps` option changes snake_case names in shapes to MixedCaps names in go structs. ``` select User { first_name, last_name, } ``` Becomes: ```go type MyQueryResult struct { FirstName string `edgedb:"first_name"` LastName string `edgedb:"last_name"` } ``` Without this option enabled names are used exactly as they appear in shapes. For example the query above would produce the following struct: ```go type MyQueryResult struct { first_name string `edgedb:"first_name"` last_name string `edgedb:"last_name"` } ``` working on #245
When edgeql-go is run, the generated function names and return values are lowercase, which makes them inaccessible.
I have
select_enabled_auth.edgeql
and a
queries.go
file to generate the code and export the queriesthe generated code is
When I go to use the returned values, I cannot call on the fields. The generated files would work fine if it's in the same package, but I have the database layer exported out.
Expected behavior
I would expect the return values to have public field names so they can be accessed turning
selectEnabledAuth
into below. It should be pascal case, or at least start with an upper letter.Versions:
edgedb-go
version: v0.13.1The text was updated successfully, but these errors were encountered: