Skip to content

Commit 596e4ff

Browse files
committed
Condition json output on opt-in settings flag
1 parent a0fea8c commit 596e4ff

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@
9898
"default": false,
9999
"description": "(Unstable) Use embedded language server for intelligent completion and hover information."
100100
},
101+
"SQLNotebook.outputJSON": {
102+
"type": "boolean",
103+
"default": false,
104+
"description": "Output JSON in addition to markdown. Other extensions may use this output type to render an interactive table."
105+
},
101106
"SQLNotebook.queryTimeout": {
102107
"type": "number",
103108
"default": 30000,

src/controller.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@ export class SQLNotebookController {
9292

9393
writeSuccess(
9494
execution,
95-
result.map((item) => [
96-
text(resultToMarkdownTable(item), 'text/markdown'),
97-
json(item),
98-
])
95+
result.map((item) => {
96+
const outputs = [text(resultToMarkdownTable(item), 'text/markdown')];
97+
if (outputJsonMimeType()) {
98+
outputs.push(json(item));
99+
}
100+
return outputs;
101+
})
99102
);
100103
}
101104
}
@@ -118,3 +121,9 @@ function writeSuccess(
118121
);
119122
execution.end(true, Date.now());
120123
}
124+
125+
function outputJsonMimeType(): boolean {
126+
return (
127+
vscode.workspace.getConfiguration('SQLNotebook').get('outputJSON') ?? false
128+
);
129+
}

0 commit comments

Comments
 (0)