We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d8c7c63 commit fb9e8faCopy full SHA for fb9e8fa
1 file changed
internal-packages/tsql/src/query/printer.ts
@@ -647,7 +647,9 @@ export class ClickHousePrinter {
647
// ORDER BY must be led by the timeBucket column (alias or full expression).
648
// Don't fight a user ordering like `ORDER BY count DESC`.
649
const leadTerm = orderBy[0];
650
- const leadExpr = leadTerm.replace(/\s+(ASC|DESC)\s*$/i, "").trim();
+ // Trim first so the direction match is anchored without a trailing `\s*$`, which
651
+ // combined with the leading `\s+` would backtrack polynomially on all-whitespace input.
652
+ const leadExpr = leadTerm.trim().replace(/\s+(?:ASC|DESC)$/i, "");
653
const matchesBucket = (expr: string): boolean =>
654
expr.toLowerCase() === bucketAlias!.toLowerCase() || expr === bucketSql;
655
if (!matchesBucket(leadExpr)) {
0 commit comments