Ensure HABTM relationships produce valid class names (Fixes #17119)
Merge pull request #17217 from codeodor/fix-17119

Ensure HABTM relationships produce valid class names (Fixes #17119)