-
Notifications
You must be signed in to change notification settings - Fork 430
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] escape some strings in query builders #231
Conversation
Codecov Report
@@ Coverage Diff @@
## master #231 +/- ##
=======================================
Coverage 62.16% 62.16%
=======================================
Files 50 50
Lines 3698 3698
=======================================
Hits 2299 2299
Misses 1097 1097
Partials 302 302
Continue to review full report at Codecov.
|
@@ -120,12 +120,12 @@ func (sb *SchemaBuilder) Swap(targetSchema string) string { | |||
|
|||
// ChangeComment returns the SQL query that will update the comment on the schema. | |||
func (sb *SchemaBuilder) ChangeComment(c string) string { | |||
return fmt.Sprintf(`ALTER SCHEMA %v SET COMMENT = '%v'`, sb.QualifiedName(), c) | |||
return fmt.Sprintf(`ALTER SCHEMA %v SET COMMENT = '%v'`, sb.QualifiedName(), EscapeString(c)) |
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 is the other QualifiedName escaped (in RemoveComment) but not this one? I can't really tell if there is a difference or not.
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.
Good catch. I think qualified names should not be escaped. Or, at least, I wasn't trying to do that in this PR.
@@ -139,7 +139,7 @@ func (vb *ViewBuilder) Unsecure() string { | |||
// Note that comment is the only parameter, if more are released this should be | |||
// abstracted as per the generic builder. | |||
func (vb *ViewBuilder) ChangeComment(c string) string { | |||
return fmt.Sprintf(`ALTER VIEW %v SET COMMENT = '%v'`, vb.QualifiedName(), c) | |||
return fmt.Sprintf(`ALTER VIEW %v SET COMMENT = '%v'`, vb.QualifiedName(), EscapeString(c)) |
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.
same here
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.
same
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.
lgtm contingent the QualifiedName escaping question
Escape comments and other string fields that are not currently escaped in our query builders.
Test Plan
References