Skip to content

Commit 92670c6

Browse files
authored
removes the selection UI on sql code block displays (#1740)
* removes the selection UI on sql code block displays
1 parent 6d3efac commit 92670c6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/sql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export function transpileSql(content: string, {id, display}: Record<string, stri
99
return id === undefined
1010
? display === "false"
1111
? `${sql};`
12-
: `display(Inputs.table(await ${sql}));`
12+
: `display(Inputs.table(await ${sql}, {select: false}));`
1313
: display === "false"
1414
? `const ${id} = await ${sql};`
15-
: `const ${id} = ((_) => (display(Inputs.table(_)), _))(await ${sql});`;
15+
: `const ${id} = ((_) => (display(Inputs.table(_, {select: false})), _))(await ${sql});`;
1616
}
1717

1818
function isValidBinding(input: string): boolean {

test/sql-test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {transpileSql} from "../src/sql.js";
33

44
describe("transpileSql(content, attributes)", () => {
55
it("compiles a sql expression", () => {
6-
assert.strictEqual(transpileSql("SELECT 1 + 2"), "display(Inputs.table(await sql`SELECT 1 + 2`));");
6+
assert.strictEqual(transpileSql("SELECT 1 + 2"), "display(Inputs.table(await sql`SELECT 1 + 2`, {select: false}));"); // prettier-ignore
77
});
88
it("compiles a sql expression with id", () => {
99
assert.strictEqual(transpileSql("SELECT 1 + 2", {id: "foo"}), "const foo = await sql`SELECT 1 + 2`;");
@@ -22,13 +22,13 @@ describe("transpileSql(content, attributes)", () => {
2222
assert.throws(() => transpileSql("SELECT 1 + 2", {id: "([foo])"}), /invalid binding/);
2323
});
2424
it("compiles a sql expression with id and display", () => {
25-
assert.strictEqual(transpileSql("SELECT 1 + 2", {id: "foo", display: ""}), "const foo = ((_) => (display(Inputs.table(_)), _))(await sql`SELECT 1 + 2`);"); // prettier-ignore
25+
assert.strictEqual(transpileSql("SELECT 1 + 2", {id: "foo", display: ""}), "const foo = ((_) => (display(Inputs.table(_, {select: false})), _))(await sql`SELECT 1 + 2`);"); // prettier-ignore
2626
});
2727
it("ignores display if display is implicit", () => {
28-
assert.strictEqual(transpileSql("SELECT 1 + 2", {display: ""}), "display(Inputs.table(await sql`SELECT 1 + 2`));"); // prettier-ignore
29-
assert.strictEqual(transpileSql("SELECT 1 + 2", {display: "t"}), "display(Inputs.table(await sql`SELECT 1 + 2`));"); // prettier-ignore
30-
assert.strictEqual(transpileSql("SELECT 1 + 2", {display: "f"}), "display(Inputs.table(await sql`SELECT 1 + 2`));"); // prettier-ignore
31-
assert.strictEqual(transpileSql("SELECT 1 + 2", {display: "true"}), "display(Inputs.table(await sql`SELECT 1 + 2`));"); // prettier-ignore
28+
assert.strictEqual(transpileSql("SELECT 1 + 2", {display: ""}), "display(Inputs.table(await sql`SELECT 1 + 2`, {select: false}));"); // prettier-ignore
29+
assert.strictEqual(transpileSql("SELECT 1 + 2", {display: "t"}), "display(Inputs.table(await sql`SELECT 1 + 2`, {select: false}));"); // prettier-ignore
30+
assert.strictEqual(transpileSql("SELECT 1 + 2", {display: "f"}), "display(Inputs.table(await sql`SELECT 1 + 2`, {select: false}));"); // prettier-ignore
31+
assert.strictEqual(transpileSql("SELECT 1 + 2", {display: "true"}), "display(Inputs.table(await sql`SELECT 1 + 2`, {select: false}));"); // prettier-ignore
3232
});
3333
it("compiles a sql expression with display=false", () => {
3434
assert.strictEqual(transpileSql("SELECT 1 + 2", {display: "false"}), "sql`SELECT 1 + 2`;");

0 commit comments

Comments
 (0)