feat: allow spaces in table/database names [DCI-752] - #30
Conversation
MySQL allows spaces in identifiers when quoted with backticks. The isSafeIdentifier validation was rejecting valid table names containing spaces.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
| func isSafeIdentifier(s string) bool { | ||
| for _, r := range s { | ||
| if !(unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' || r == '-') { | ||
| if !(unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' || r == '-' || r == ' ') { |
There was a problem hiding this comment.
This addition will make space also a valid char like letters, digits etc.
Now sure this is our intention here. Why not just replace space with "_"? Already from Backend side, not here...
There was a problem hiding this comment.
Hey Aaron,
We can't normalize (replace space with _) on the backend side because of how the binlog listener works:
- The binlog streams events by actual table name - When MySQL sends binlog events, they contain the exact table name as it exists in the database (tbl_some_name _CC_triggered_email_list with the space)
- We filter which tables to listen to using IncludeTableRegex - This regex must match the exact table name from the binlog events
- If we normalize before receiving from backend:
- Backend sends us tbl_...GI_CC... (normalized, with underscore)
- Binlog streams events for tbl_..._GI CC... (actual name, with space)
- They won't match → we miss all events for that table
The table name in IncludeTableRegex must be identical to what MySQL has, otherwise the binlog listener won't capture those events. We're not creating the space - we're just allowing it to pass through because the customer's MySQL database actually has a table with a space in its name.
|
Closing this PR. After discussion with product, we decided not to support table names with spaces in CDC. Instead, we'll add validation on the CDC side to raise a clear error during initialization when table names contain spaces, and block this in the UI mapping as well |
MySQL allows spaces in identifiers when quoted with backticks. The isSafeIdentifier validation was rejecting valid table names containing spaces.