Skip to content

Commit a6e123d

Browse files
committed
Change how scrolling query is executed
1 parent 5c82207 commit a6e123d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/language/results/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ResultSetPanelProvider {
3636

3737
const statement = [
3838
`SET CURRENT SCHEMA = '${config.currentLibrary.toUpperCase()}'`,
39-
`WITH SCROLLING AS (${message.query}) SELECT * FROM SCROLLING LIMIT ${message.limit} OFFSET ${message.offset}`,
39+
`${message.query} LIMIT ${message.limit} OFFSET ${message.offset}`,
4040
].join(`;\n`);
4141

4242
let data = [];
@@ -147,11 +147,12 @@ exports.initialise = (context) => {
147147
});
148148

149149
} else {
150-
151-
if (statement.content.toUpperCase().startsWith(`SELECT`) && !statement.content.toUpperCase().includes(`LIMIT`)) {
150+
if (statement.type === `statement` && this.isBasicStatement(statement.content)) {
151+
// If it's a basic statement, we can let it scroll!
152152
resultSetProvider.setScrolling(statement.content);
153153

154154
} else {
155+
// Otherwise... it's a bit complicated.
155156
statement.content = [
156157
`SET CURRENT SCHEMA = '${config.currentLibrary.toUpperCase()}'`,
157158
statement.content
@@ -234,6 +235,11 @@ exports.initialise = (context) => {
234235
)
235236
}
236237

238+
exports.isBasicStatement = (statement) => {
239+
const basicStatement = statement.trim().toUpperCase();
240+
241+
return statement.startsWith(`SELECT`) && !statement.includes(`LIMIT`);
242+
}
237243

238244
/**
239245
* @param {vscode.TextEditor} editor

0 commit comments

Comments
 (0)