File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 88def _table_name_for_classification (c : Classification ) -> str :
99 """
1010 Deterministic mapping from classification name to SQL table name.
11- Removes spaces and special characters, keeps only alphanumeric.
12- Example: "Product Brochure/Leaflet" -> "productbrochureleaflet "
13- Example: "Robot Specifications" -> "robotspecifications "
11+ Converts spaces and special characters to underscores , keeps only alphanumeric and underscores .
12+ Example: "Product Brochure/Leaflet" -> "product_brochure_leaflet "
13+ Example: "Robot Specifications" -> "robot_specifications "
1414 """
15- # Remove spaces and convert to lowercase
15+ # Convert to lowercase
1616 name = c .name .lower ()
17- # Keep only alphanumeric characters
18- name = "" .join (char if char .isalnum () else "" for char in name )
17+ # Replace non-alphanumeric characters with underscores
18+ name = "" .join (char if char .isalnum () else "_" for char in name )
19+ # Remove consecutive underscores and strip leading/trailing underscores
20+ while "__" in name :
21+ name = name .replace ("__" , "_" )
22+ name = name .strip ("_" )
1923
2024 # Ensure it starts with a letter (not a number)
2125 if name and name [0 ].isdigit ():
You can’t perform that action at this time.
0 commit comments