From e89732a41ad93e10296440881c9e81eac9c3972d Mon Sep 17 00:00:00 2001 From: Collin Stevens Date: Sat, 16 Dec 2023 12:20:33 -1000 Subject: [PATCH] add dialect specific truncate snippet for sqlite (#806) --- site/docs/getting-started/Summary.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/site/docs/getting-started/Summary.tsx b/site/docs/getting-started/Summary.tsx index 9a078371b..d28ccb5e2 100644 --- a/site/docs/getting-started/Summary.tsx +++ b/site/docs/getting-started/Summary.tsx @@ -39,10 +39,17 @@ const dialectSpecificCodeSnippets: Record = { .execute()`, } +const dialectSpecificTruncateSnippets: Record = { + postgresql: `await sql\`truncate table \${sql.table('person')}\`.execute(db)`, + mysql: `await sql\`truncate table \${sql.table('person')}\`.execute(db)`, + sqlite: `await sql\`delete from \${sql.table('person')}\`.execute(db)`, +} + export function Summary(props: PropsWithDialect) { const dialect = props.dialect || 'postgresql' const dialectSpecificCodeSnippet = dialectSpecificCodeSnippets[dialect] + const dialectSpecificTruncateSnippet = dialectSpecificTruncateSnippets[dialect] const prettyDialectName = PRETTY_DIALECT_NAMES[dialect] return ( @@ -66,7 +73,7 @@ ${dialectSpecificCodeSnippet} }) afterEach(async () => { - await sql\`truncate table \${sql.table('person')}\`.execute(db) + ${dialectSpecificTruncateSnippet} }) after(async () => {