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

add addIndex & dropIndex @ AlterTableBuilder #522

Closed

Conversation

Gaspero
Copy link
Contributor

@Gaspero Gaspero commented May 28, 2023

closes #507
closes #508

  • implement
  • test
  • document

@vercel
Copy link

vercel bot commented May 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kysely ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2023 1:59pm

@igalklebanov igalklebanov added enhancement New feature or request mysql Related to MySQL api Related to library's API labels May 28, 2023
Copy link
Member

@igalklebanov igalklebanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey 👋

Thank you! 💪

Looks good for the most part, a few comments and suggestions..


describe('add index', () => {
it('should add an index', async () => {
const builder = ctx.db.schema
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this uniform and call it query.

Suggested change
const builder = ctx.db.schema
const query = ctx.db.schema

Same with all occurrences.

@@ -1890,6 +1890,145 @@ for (const dialect of DIALECTS) {
await builder.execute()
})
})

describe('add index', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sub-suite should be under the existing alter table suite.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should break this test file into multiple files, but it is not in scope for this PR.

})
})

describe('drop index', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as add index suite, this sub-suite should be under the existing alter table suite.

Comment on lines +232 to +238
return new AlterTableAddIndexBuilder({
...this.#props,
indexBuilder: new AddIndexBuilder({
...this.#props,
node: AddIndexNode.create({ name: IdentifierNode.create(indexName) }),
}),
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why both AlterTableAddIndexBuilder and AddIndexBuilder exist. Mind explaining? 😕

return node.kind === 'AddIndexNode'
},

create(index: Omit<AddIndexNode, 'kind'>): AddIndexNode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there ever a situation when it's created with anything but a name at first?
If not, accept a single argument name here.

@harrytran998
Copy link

Hi @igalklebanov, can you take the rest of these features? Bcs currently, this in the only way to create an index on a table as I know with Kysely.

Thank you!

@Gaspero
Copy link
Contributor Author

Gaspero commented Aug 4, 2023

Hey everyone!

Sorry for the delay in applying suggestions. I hope I will manage to fix everything util the end of August as I am currently stuck with my pet project.

Bcs currently, this in the only way to create an index on a table as I know with Kysely.

@harrytran998 AFAIK in MySQL you could use create index statement.
For reference see tests:

it('should create an index', async () => {

@koskimas
Copy link
Member

This PR seems to be dead. Closing.

@koskimas koskimas closed this Sep 20, 2023
@Gaspero
Copy link
Contributor Author

Gaspero commented Oct 2, 2023

Hey everyone!

Sorry, I kinda lost track of time. I've completed the milestone of the project I was working at. I hope I will be able to finish implementation of this features now.

I've made a separate branch where I applied @igalklebanov suggestions https://github.com/Gaspero/kysely/tree/add-and-remove-index-in-alter-table-v2

Don't you mind if I open a new PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API enhancement New feature or request mysql Related to MySQL waiting for submitter response
Projects
None yet
4 participants