Skip to content

fix: use split_whitespace() instead of replace(' ') in proc macros to…#3031

Merged
tyt2y3 merged 1 commit intoSeaQL:masterfrom
owjs3901:fix/proc-macro-whitespace-stripping
Apr 2, 2026
Merged

fix: use split_whitespace() instead of replace(' ') in proc macros to…#3031
tyt2y3 merged 1 commit intoSeaQL:masterfrom
owjs3901:fix/proc-macro-whitespace-stripping

Conversation

@owjs3901
Copy link
Copy Markdown
Contributor

@owjs3901 owjs3901 commented Apr 1, 2026

… handle newlines in long type paths

PR Info

  • Fix DeriveActiveModelEx (and other derive macros) producing compile_error!("unexpected token") when entity module names are long (~50+ characters)
  • Replace .replace(' ', "") with .split_whitespace().collect() across all 11 occurrences in sea-orm-macros

Bug Fixes

  • [ x ] proc_macro2::TokenStream::to_string() inserts \n (newlines) for line-wrapping when the output exceeds ~80 characters. The existing code used .replace(' ', "") to normalize the stringified type, but this only strips spaces — not newlines.

When entity paths like HasMany<super::estimate_user_checker_setting::Entity> are long enough to trigger line-wrapping, the extracted path retains an embedded \n:

image As shown in the image, an error occurs when a module with a long name is used inside HasMany.
// Before (breaks on long paths)
.replace(' ', "")

// After (strips all whitespace including \n, \r, \t)
.split_whitespace().collect()

@Huliiiiii Huliiiiii requested review from Expurple and tyt2y3 April 1, 2026 20:52
@tyt2y3
Copy link
Copy Markdown
Member

tyt2y3 commented Apr 2, 2026

Note to self: this might not be the best approach to detect Option<T>, worth investigating later.

@tyt2y3 tyt2y3 merged commit 6b09f97 into SeaQL:master Apr 2, 2026
39 checks passed
@owjs3901 owjs3901 deleted the fix/proc-macro-whitespace-stripping branch April 2, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants