Skip to content

Commit

Permalink
Merge branch 'master' into fix-if-inside-with-is-any
Browse files Browse the repository at this point in the history
  • Loading branch information
igalklebanov authored Dec 18, 2023
2 parents 0f894ff + 680eb46 commit 2fa1979
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions site/docs/getting-started/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,23 @@ const dialectSpecificCodeSnippets: Record<Dialect, string> = {
.addColumn('first_name', 'varchar(255)', (cb) => cb.notNull())
.addColumn('last_name', 'varchar(255)')
.addColumn('gender', 'varchar(50)', (cb) => cb.notNull())
.addColumn('created_at', 'timestampz', (cb) =>
.addColumn('created_at', 'timestamp', (cb) =>
cb.notNull().defaultTo(sql\`current_timestamp\`)
)
.execute()`,
}

const dialectSpecificTruncateSnippets: Record<Dialect, string> = {
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 (
Expand All @@ -66,34 +73,34 @@ ${dialectSpecificCodeSnippet}
})
afterEach(async () => {
await sql\`truncate table \${sql.table('person')}\`.execute(db)
${dialectSpecificTruncateSnippet}
})
after(async () => {
await db.schema.dropTable('person').execute()
})
it('should find a person with a given id', () => {
it('should find a person with a given id', async () => {
await PersonRepository.findPersonById(123)
})
it('should find all people named Arnold', () => {
it('should find all people named Arnold', async () => {
await PersonRepository.findPeople({ first_name: 'Arnold' })
})
it('should update gender of a person with a given id', () => {
it('should update gender of a person with a given id', async () => {
await PersonRepository.updatePerson(123, { gender: 'woman' })
})
it('should create a person', () => {
it('should create a person', async () => {
await PersonRepository.createPerson({
first_name: 'Jennifer',
last_name: 'Aniston',
gender: 'woman',
})
})
it('should delete a person with a given id', () => {
it('should delete a person with a given id', async () => {
await PersonRepository.deletePerson(123)
})
})`}
Expand Down

0 comments on commit 2fa1979

Please sign in to comment.