Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

nit: capitalize sql statements (#1859)

Myles Scolnickc3b2f3c52feb
diff --git a/frontend/src/core/codemirror/language/__tests__/sql.test.ts b/frontend/src/core/codemirror/language/__tests__/sql.test.ts
index 223668b703..5fe44349f0 100644
--- a/frontend/src/core/codemirror/language/__tests__/sql.test.ts
+++ b/frontend/src/core/codemirror/language/__tests__/sql.test.ts
@@ -33,25 +33,25 @@ describe("SQLLanguageAdapter", () => {
});
it("should extract inner SQL from triple double-quoted strings", () => {
- const pythonCode = '_df = mo.sql("""select * from {df}""")';
+ const pythonCode = '_df = mo.sql("""SELECT * FROM {df}""")';
const [innerCode, offset] = adapter.transformIn(pythonCode);
- expect(innerCode).toBe("select * from {df}");
+ expect(innerCode).toBe("SELECT * FROM {df}");
expect(adapter.dataframeName).toBe("_df");
expect(offset).toBe(16);
});
it("should handle single double-quoted strings", () => {
- const pythonCode = 'next_df = mo.sql("select * from {df}")';
+ const pythonCode = 'next_df = mo.sql("SELECT * FROM {df}")';
const [innerCode, offset] = adapter.transformIn(pythonCode);
- expect(innerCode).toBe("select * from {df}");
+ expect(innerCode).toBe("SELECT * FROM {df}");
expect(adapter.dataframeName).toBe("next_df");
expect(offset).toBe(18);
});
it("should handle triple single-quoted strings", () => {
- const pythonCode = "next_df = mo.sql('''select * \nfrom {df}''')";
+ const pythonCode = "next_df = mo.sql('''SELECT * \nFROM {df}''')";
const [innerCode, offset] = adapter.transformIn(pythonCode);
- expect(innerCode).toBe("select * \nfrom {df}");
+ expect(innerCode).toBe("SELECT * \nFROM {df}");
expect(offset).toBe(20);
});
@@ -70,37 +70,37 @@ describe("SQLLanguageAdapter", () => {
});
it("simple sql", () => {
- const pythonCode = 'next_df = mo.sql("select * from {df}")';
+ const pythonCode = 'next_df = mo.sql("SELECT * FROM {df}")';
const [innerCode, offset] = adapter.transformIn(pythonCode);
- expect(innerCode).toBe("select * from {df}");
+ expect(innerCode).toBe("SELECT * FROM {df}");
expect(offset).toBe(18);
});
it("should trim strings with leading and trailing whitespace", () => {
- const pythonCode = 'next_df = mo.sql(""" \nselect * from {df}\n """)';
+ const pythonCode = 'next_df = mo.sql(""" \nSELECT * FROM {df}\n """)';
const [innerCode, offset] = adapter.transformIn(pythonCode);
- expect(innerCode).toBe("select * from {df}");
+ expect(innerCode).toBe("SELECT * FROM {df}");
expect(offset).toBe(20);
});
it("should handle space around the f-strings", () => {
- const pythonCode = 'next_df = mo.sql(\n\t"""\nselect * from {df}\n"""\n)';
+ const pythonCode = 'next_df = mo.sql(\n\t"""\nSELECT * FROM {df}\n"""\n)';
const [innerCode, offset] = adapter.transformIn(pythonCode);
- expect(innerCode).toBe("select * from {df}");
+ expect(innerCode).toBe("SELECT * FROM {df}");
expect(offset).toBe(22);
});
});
describe("transformOut", () => {
it("should wrap SQL code with triple double-quoted string format", () => {
- const code = "select * from {df}";
+ const code = "SELECT * FROM {df}";
adapter.lastQuotePrefix = "";
adapter.dataframeName = "my_df";
const [wrappedCode, offset] = adapter.transformOut(code);
expect(wrappedCode).toMatchInlineSnapshot(`
"my_df = mo.sql(
f"""
- select * from {df}
+ SELECT * FROM {df}
"""
)"
`);
@@ -111,7 +111,7 @@ describe("SQLLanguageAdapter", () => {
describe("isSupported", () => {
it("should return true for supported sql string formats", () => {
expect(
- adapter.isSupported('df2 = mo.sql("""select * from {df}""")'),
+ adapter.isSupported('df2 = mo.sql("""SELECT * FROM {df}""")'),
).toBe(true);
expect(adapter.isSupported("my_df = mo.sql('')")).toBe(true);
expect(adapter.isSupported('df = mo.sql("")')).toBe(true);
@@ -130,7 +130,7 @@ describe("SQLLanguageAdapter", () => {
});
it("should return false sequences that look like sql but are not", () => {
- const once = 'df = mo.sql("""select * from {df}""")';
+ const once = 'df = mo.sql("""SELECT * FROM {df}""")';
const pythonCode = [once, once].join("\n");
expect(adapter.isSupported(pythonCode)).toBe(false);
});
diff --git a/frontend/src/core/codemirror/language/sql.ts b/frontend/src/core/codemirror/language/sql.ts
index 21826639cf..a1ac81ce1d 100644
--- a/frontend/src/core/codemirror/language/sql.ts
+++ b/frontend/src/core/codemirror/language/sql.ts
@@ -47,7 +47,7 @@ const regexes = pairs.map(
*/
export class SQLLanguageAdapter implements LanguageAdapter {
readonly type = "sql";
- readonly defaultCode = `_df = mo.sql(f"""select * from """)`;
+ readonly defaultCode = `_df = mo.sql(f"""SELECT * FROM """)`;
dataframeName = "_df";
lastQuotePrefix: QuotePrefixKind = "f";