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

bugfix: arguments with null default were required #509

Merged
merged 9 commits into from
Apr 9, 2024
Merged

Conversation

imor
Copy link
Contributor

@imor imor commented Apr 8, 2024

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

UDF args with a default value of null were either required or had a default value of "NULL" in case of string.

What is the new behavior?

UDF args with a null default value will be optional.

Additional context

Fixes #507

@imor imor changed the title arguments with null default are still required bugfix: arguments with null default were required Apr 8, 2024
src/sql_types.rs Outdated Show resolved Hide resolved
let trimmed = default_str.trim();
if trimmed.starts_with("NULL::") {
Copy link
Contributor

Choose a reason for hiding this comment

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

are you confident this is always reliable wrt uppercase/lowercase? Will it alway be cast with a ::?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

are you confident this is always reliable wrt uppercase/lowercase?

Yes, Postgres converts all cases into capitals. Added a test for this.

Will it alway be cast with a ::?

A <arg> <type> default null form is always converted into a cast of the form NULL::<type>. Other, more complex forms of expressions might not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also updated docs with the caveat that only simple default null are supported for now.

@olirice olirice merged commit a403fce into master Apr 9, 2024
4 checks passed
@olirice olirice deleted the null_default branch April 9, 2024 19:47
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.

UDF nullable arguments not being translated properly
2 participants