Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

Commit d403629

Browse files
authored
Merge pull request #237 from ptomasroos/fix-232
Allow auto calculated limit to be inserted a specific place instead of just appended to the end
2 parents 19a8f49 + a697b37 commit d403629

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/datasource.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,14 @@ export class BigQueryDatasource {
528528
}
529529
const limit = q.match(/[^]+(\bLIMIT\b)/gi);
530530
if (limit == null) {
531-
q += " LIMIT " + options.maxDataPoints;
531+
const limitStatement = " LIMIT " + options.maxDataPoints;
532+
const limitPosition = q.match(/\$__limitPosition/g);
533+
if (limitPosition !== null)
534+
{
535+
q = q.replace(/\$__limitPosition/g, limitStatement);
536+
} else {
537+
q += limitStatement;
538+
}
532539
}
533540
return q;
534541
}

0 commit comments

Comments
 (0)