-
Notifications
You must be signed in to change notification settings - Fork 107
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
mixed case support for CDC mirrors in Snowflake and Postgres #589
Conversation
@@ -497,6 +497,7 @@ func (c *PostgresConnector) generateFallbackStatements(destinationTableIdentifie | |||
} | |||
} | |||
flattenedCastsSQL := strings.TrimSuffix(strings.Join(flattenedCastsSQLArray, ","), ",") | |||
parsedDstTable, _ := utils.ParseSchemaTable(destinationTableIdentifier) |
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.
put this at top before normalizedTableSchema
would probably run into a nil dereference & handle errors
@@ -529,6 +530,7 @@ func (c *PostgresConnector) generateMergeStatement(destinationTableIdentifier st | |||
for i, columnName := range columnNames { | |||
columnNames[i] = fmt.Sprintf("\"%s\"", columnName) | |||
} | |||
parsedDstTable, _ := utils.ParseSchemaTable(destinationTableIdentifier) |
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.
On one level it feels like this could be made more efficient with a utils.SanitizeSchemaTable
where it'd avoid allocations in case where destinationTableIdentifier == parsedDstTable.String()
but in another level it seems like you're already too late here if for stranger names like those containing a period. But maybe character stripping avoids that for now
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.
func SanitizeSchemaTable(dirty string) {
var sb strings.Builder
sb.Grow(len(dirty) + 4)
sb.WriteRune('"')
sb.WriteString(strings.Replace(dirty, ".", "\".\"", 1))
sb.WriteRune('"')
return sb.String()
}
Something like this. Would have to profile to see if it actually brings any benefit. Probably over optimizing. This draft also fails to include the return dirty if dirty matches [a-zA-Z0-9.]+
logic
// https://www.alberton.info/dbms_identifiers_and_case_sensitivity.html | ||
// Snowflake follows the SQL standard, but Postgres does the opposite. | ||
// Ergo, we suffer. | ||
if strings.ToLower(identifier) == identifier { |
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.
A utils.IsLower(string)
/ utils.IsUpper(string)
could be implemented using unicode
package's IsLetter
/ IsUpper
/ IsLower
} | ||
} | ||
|
||
switch appendMode { |
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.
switch appendMode { | |
if appendMode { |
1834283
to
7920d15
Compare
No description provided.