-
-
Notifications
You must be signed in to change notification settings - Fork 238
Unwrap inputs to REGEXP_LIKE, REPLACE, and RPAD/LPAD functions. #2964
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
Changes from 2 commits
02234b9
acbdefd
49ee42e
1067759
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| exec | ||
| create table tabletest ( | ||
| i int primary key, | ||
| s varchar(20) not null | ||
| s text not null | ||
| ) | ||
| ---- | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,7 +169,19 @@ func (p *Pad) Eval( | |
| return nil, err | ||
| } | ||
|
|
||
| return padString(str.(string), length.(int64), padStr.(string), p.padType) | ||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again on the block?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
| str, _, err := sql.Unwrap[string](ctx, str) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| padStr, _, err := sql.Unwrap[string](ctx, padStr) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return padString(str, length.(int64), padStr, p.padType) | ||
| } | ||
| } | ||
|
|
||
| func padString(str string, length int64, padStr string, padType padType) (string, error) { | ||
|
|
||
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.
Why the additional block?
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.
The blocks are there so that I can redeclare
fromStret al as strings instead ofinterface{}. Without the block I'd need to pick new names for the unwrapped versions, which would be noisy.