| 338 | }; |
| 339 | |
| 340 | static std::string sanitizeSQLAlias(std::string alias) { |
| 341 | for (auto& ch : alias) { |
| 342 | if (!std::isalnum(static_cast<unsigned char>(ch)) && ch != '_') { |
| 343 | ch = '_'; |
| 344 | } |
| 345 | } |
| 346 | if (alias.empty() || std::isdigit(static_cast<unsigned char>(alias[0]))) { |
| 347 | alias = "col_" + alias; |
| 348 | } |
| 349 | return alias; |
| 350 | } |
| 351 | |
| 352 | // Build the SQL join query string and collect column names for result mapping. |
| 353 | // Keep result column names SQL-safe while using display names that preserve the user's labels. |