From 1c4f1d9f0e76fc98a3ca1c83f769564580422d3a Mon Sep 17 00:00:00 2001 From: eitam Date: Thu, 8 Jan 2026 11:30:20 +0200 Subject: [PATCH] feat: allow spaces in table/database names MySQL allows spaces in identifiers when quoted with backticks. The isSafeIdentifier validation was rejecting valid table names containing spaces. --- canal/canal.go | 2 +- canal/canal_test.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/canal/canal.go b/canal/canal.go index d18a570cc..5fc7c0733 100644 --- a/canal/canal.go +++ b/canal/canal.go @@ -436,7 +436,7 @@ func (c *Canal) checkBinlogRowFormat() error { 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 == ' ') { return false } } diff --git a/canal/canal_test.go b/canal/canal_test.go index 1e5e12672..46bb192b3 100644 --- a/canal/canal_test.go +++ b/canal/canal_test.go @@ -508,8 +508,10 @@ func TestIsSafeIdentifier(t *testing.T) { {"unicode letters", "tàble", true}, {"chinese characters", "表格", true}, + // Space is valid (MySQL allows spaces in identifiers when quoted) + {"space", "my table", true}, + // Invalid identifiers - {"space", "my table", false}, {"dot", "my.table", false}, {"at symbol", "@table", false}, {"hash symbol", "#table", false},