-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Allow providing a config value to remove optional parameter generation #556
Comments
I'd really love this feature. I recently wrote an upsert query and missed a The majority of our columns are marked That said, is there a reason pg-typed can't determine whether a parameter is required/optional from the query itself? |
in addition this would allow copy pasting the SQL into pg console for debugging. |
Seems we've reached a critical mass for me to bother writing a PR 😄 See #582 I haven't been able to test it though. |
Is your feature request related to a problem? Please describe.
It's fairly easy when refactoring nullable variables to miss somewhere that it's supposed to be changed. For non-nullable variables, there's a fairly reliable catch - as the variable is required to be provided to the
query.run(params, conn)
function, Typescript will raise an error.However, if the variable is nullable, as of #482 nullable variables are now optional, so they do not raise an error if you provide a variable with the wrong name (typescript's excess property checking often does not catch these cases, never for me 😞).
Describe the solution you'd like
Provide a feature flag to the config file to remove the optional parameter type for nullable types. Something like
noOptionalParameters: boolean
.I'm just testing if you'll like this feature, or if you'll want a different name for the flag. I can take responsibility for writing it, it's a very easy PR to make - prob <10 lines of code changes, and a few tests.
The text was updated successfully, but these errors were encountered: