-
Notifications
You must be signed in to change notification settings - Fork 804
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
refactor: Remove ParsedGoType
from codegen.proto, pass in opts as JSON
#2918
Conversation
The `ParsedGoType` configuration only applies to Go, so we remove it from the codegen plugin proto and instead pass the configuration as JSON to be unmarshaled by the codegen/golang package like other options. Eventually we will need to push all of the validation of overrides from internal/config into the codegen/golang package, but that's a fair bit of work so I didn't push it here. Aside from the proto change, which is obviously important, the other meaningful change is to generate.go on line 421, and the function implementation in shim.go. The types in opts/override.go are just recreations of what the plugin proto types were.
585bec5
to
41343ab
Compare
QuerySetOverrides []Override `json:"overrides,omitempty"` | ||
QuerySetRename json.RawMessage `json:"rename,omitempty"` // Unused, TODO merge with req.Settings.Rename | ||
|
||
Overrides []GoOverride `json:"-"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We consolidate all overrides here and only use overrides parsed from JSON options and overrides coming in from req.Settings.Overrides
within ParseOpts()
below to build this slice.
@@ -59,11 +58,10 @@ func mergeImports(imps ...fileImports) [][]ImportSpec { | |||
} | |||
|
|||
type importer struct { | |||
Settings *plugin.Settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having all overrides in Options
lets us drop this field
}, | ||
"go": { | ||
"emit_interface": false, | ||
"emit_json_tags": false, | ||
"emit_db_tags": false, | ||
"emit_prepared_queries": false, | ||
"emit_exact_table_names": false, | ||
"emit_empty_slices": false, | ||
"emit_exported_queries": false, | ||
"emit_result_struct_pointers": false, | ||
"emit_params_struct_pointers": false, | ||
"emit_methods_with_db_argument": false, | ||
"json_tags_case_style": "", | ||
"package": "", | ||
"out": "", | ||
"sql_package": "", | ||
"sql_driver": "", | ||
"output_db_file_name": "", | ||
"output_models_file_name": "", | ||
"output_querier_file_name": "", | ||
"output_copyfrom_file_name": "", | ||
"output_files_suffix": "", | ||
"emit_enum_valid_method": false, | ||
"emit_all_enum_values": false, | ||
"inflection_exclude_table_names": [], | ||
"emit_pointers_for_null_types": false, | ||
"query_parameter_limit": 1, | ||
"output_batch_file_name": "", | ||
"json_tags_id_uppercase": false, | ||
"omit_unused_structs": false | ||
}, | ||
"json": { | ||
"out": "", | ||
"indent": "", | ||
"filename": "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cleanup from previous change in #2822
Overrides
from Settings
in codegen.proto, pass in JSON optsParsedGoType
from codegen.proto, pass in opts as JSON
# package override | ||
error generating code: bad syntax for struct tag pair |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because struct tags get parsed in the codegen plugin now
8691140
to
af4a202
Compare
The
ParsedGoType
configuration only applies to Go, so we remove it from the codegen plugin proto and instead pass the configuration as JSON to be unmarshaled by the codegen/golang package like other options.