Skip to content
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

fix #533 in which a default arg was marked as required #534

Merged
merged 2 commits into from
Jun 27, 2024
Merged

Conversation

imor
Copy link
Contributor

@imor imor commented Jun 25, 2024

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

UDF with a complex expression as default value for an argument made the argument required.

What is the new behavior?

The argument is no longer required now and if it is omitted it will take on the default value. Complex default expressions like function calls or arithmetic expressions etc. will not be evaluated but will be included as is when returning them in response to introspection queries.

Additional context

Fixes #533

"name": "UUID", +
"ofType": null +
}, +
"defaultValue": "uid()" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to show the SQL logic of the default value here

Would it make sense to make the field nullable and not display the default value. I think we've used that approach in the past?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood correctly, your concern is only about the default value being a SQL expression, because the field is already nullable, right? In that case, we can replace uid() here with an empty string or something like <omittted> to indicate the complex nature of the default expression. We should probably also update the docs to explain why default value is an empty string or <omitted>.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concern ... default value being a SQL expression

yeah exactly. I think it should be nullable (already done) and the defaultValue should be NULL.

Thats how Postgraphile handles it (screenshot), so seems like a safe bet

Screenshot 2024-06-26 at 11 09 04 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@imor imor requested a review from olirice June 27, 2024 08:12
Copy link
Contributor

@olirice olirice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect, TY

@olirice olirice merged commit 5218009 into master Jun 27, 2024
4 checks passed
@olirice olirice deleted the fix_533 branch June 27, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stored Procedure Param with Default is Marked as Required
2 participants