diff --git a/web/components/DatabaseTableHeader/utils.test.ts b/web/components/DatabaseTableHeader/utils.test.ts index 81f2bbce..1390daec 100644 --- a/web/components/DatabaseTableHeader/utils.test.ts +++ b/web/components/DatabaseTableHeader/utils.test.ts @@ -1,4 +1,4 @@ -import { sampleQuery } from "./utils"; +import { DEFAULT_LIMIT, sampleQuery } from "./utils"; describe("tests sampleQuery", () => { const tests: Array<{ @@ -8,22 +8,22 @@ describe("tests sampleQuery", () => { }> = [ { desc: "Keyless table", - expectedQuery: `SELECT * FROM \`Keyless table\``, + expectedQuery: `SELECT * FROM \`Keyless table\`\nLIMIT ${DEFAULT_LIMIT};`, tableName: "Keyless table", }, { desc: "One key and data", - expectedQuery: `SELECT * FROM \`One key and data table\``, + expectedQuery: `SELECT * FROM \`One key and data table\`\nLIMIT ${DEFAULT_LIMIT};`, tableName: "One key and data table", }, { desc: "Two Key", - expectedQuery: `SELECT * FROM \`Two Keys table\``, + expectedQuery: `SELECT * FROM \`Two Keys table\`\nLIMIT ${DEFAULT_LIMIT};`, tableName: "Two Keys table", }, { desc: "Two Keys and data", - expectedQuery: `SELECT * FROM \`Two Keys and data table\``, + expectedQuery: `SELECT * FROM \`Two Keys and data table\`\nLIMIT ${DEFAULT_LIMIT};`, tableName: "Two Keys and data table", }, { diff --git a/web/components/DatabaseTableHeader/utils.ts b/web/components/DatabaseTableHeader/utils.ts index b31fd409..93de9327 100644 --- a/web/components/DatabaseTableHeader/utils.ts +++ b/web/components/DatabaseTableHeader/utils.ts @@ -1,5 +1,6 @@ import { isDoltSystemTable } from "@lib/doltSystemTables"; +export const DEFAULT_LIMIT = 1000; const exampleCreateTable = `CREATE TABLE tablename (pk INT, col1 VARCHAR(255), PRIMARY KEY (pk));`; export function getSqlString( @@ -27,8 +28,7 @@ export function getEditorString( return query ?? sampleQuery(tableName ?? ""); } -function addEmptyLines(firstLine: string): string { - const lines = [firstLine]; +function addEmptyLines(lines: string[]): string { // eslint-disable-next-line no-empty while (lines.push("") < 5) {} return lines.join("\n"); @@ -36,9 +36,12 @@ function addEmptyLines(firstLine: string): string { export function sampleQuery(tableName?: string): string { if (!tableName || isDoltSystemTable(tableName)) { - return addEmptyLines("SHOW TABLES;"); + return addEmptyLines(["SHOW TABLES;"]); } - return addEmptyLines(`SELECT * FROM \`${tableName}\`;`); + return addEmptyLines([ + `SELECT * FROM \`${tableName}\``, + `LIMIT ${DEFAULT_LIMIT};`, + ]); } export function sampleCreateQueryForEmpty(): string { @@ -50,5 +53,5 @@ export function sampleCreateQueryForEmpty(): string { ");", ]; - return lines.join("\n"); + return addEmptyLines(lines); } diff --git a/web/components/pageComponents/ConfigurationPage/Form.tsx b/web/components/pageComponents/ConfigurationPage/Form.tsx index c2ed36ab..ba305b8b 100644 --- a/web/components/pageComponents/ConfigurationPage/Form.tsx +++ b/web/components/pageComponents/ConfigurationPage/Form.tsx @@ -26,15 +26,16 @@ export default function Form(props: Props) {