Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operation-node-transformer fixed: #107

Merged
merged 1 commit into from
Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/operation-node/operation-node-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ export class OperationNodeTransformer {
where: this.transformNode(node.where),
returning: this.transformNode(node.returning),
with: this.transformNode(node.with),
orderBy: this.transformNode(node.orderBy),
limit: this.transformNode(node.limit),
}
}

Expand Down Expand Up @@ -619,6 +621,7 @@ export class OperationNodeTransformer {
return {
kind: 'CreateSchemaNode',
schema: this.transformNode(node.schema),
ifNotExists: node.ifNotExists,
}
}

Expand Down
102 changes: 102 additions & 0 deletions test/node/src/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,108 @@ for (const dialect of BUILT_IN_DIALECTS) {
})
})

describe('create schema', () => {
if (dialect === 'postgres' || dialect === 'mysql') {
beforeEach(cleanup)
afterEach(cleanup)

it('should create a schema', async () => {
const builder = ctx.db.schema
.createSchema('pets')

testSql(builder, dialect, {
postgres: {
sql: `create schema "pets"`,
parameters: [],
},
mysql: {
sql: "create schema `pets`",
parameters: [],
},
sqlite: NOT_SUPPORTED
})

await builder.execute()
})

it('should create a schema if not exists', async () => {
const builder = ctx.db.schema
.createSchema('pets')
.ifNotExists()

testSql(builder, dialect, {
postgres: {
sql: `create schema if not exists "pets"`,
parameters: [],
},
mysql: {
sql: "create schema if not exists `pets`",
parameters: [],
},
sqlite: NOT_SUPPORTED,
})

await builder.execute()
})
}

async function cleanup() {
await ctx.db.schema.dropSchema('pets').ifExists().execute()
}
})

describe('drop schema', () => {
if (dialect === 'postgres' || dialect === 'mysql') {
beforeEach(cleanup)
afterEach(cleanup)

it('should create a schema', async () => {
await ctx.db.schema.createSchema('pets').execute();

const builder = ctx.db.schema
.dropSchema('pets')

testSql(builder, dialect, {
postgres: {
sql: `drop schema "pets"`,
parameters: [],
},
mysql: {
sql: "drop schema `pets`",
parameters: [],
},
sqlite: NOT_SUPPORTED
})

await builder.execute()
})

it('should drop a schema if exists', async () => {
const builder = ctx.db.schema
.dropSchema('pets')
.ifExists()

testSql(builder, dialect, {
postgres: {
sql: `drop schema if exists "pets"`,
parameters: [],
},
mysql: {
sql: "drop schema if exists `pets`",
parameters: [],
},
sqlite: NOT_SUPPORTED,
})

await builder.execute()
})
}

async function cleanup() {
await ctx.db.schema.dropSchema('pets').ifExists().execute()
}
})

describe('alter table', () => {
beforeEach(async () => {
await ctx.db.schema
Expand Down