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

feat: handle different placing of type names #1470

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

emilsivervik
Copy link
Contributor

Hey,

First of all I just want to thank for all the awesome work on this library!

I've came across something that didn't work as expected a couple of months ago and created a fix for myself but now took the time to bring it here also. I'm sure there are some things left to do so I would appreciate some rubber-🦆

The issue is when trying to parse create a create statement

// Working
CREATE TABLE tb (id INT, KEY USING HASH (id))
// Not working
CREATE TABLE tb (id INT, KEY (id) USING HASH)

There was also an issue using order on the keys, such as this

CREATE TABLE tb (id INT, KEY USING HASH (id ASC))

which I'm not entirely sure how you'd like to handle, from my side I just did what was the appropriate solution (not using it) but I'd imagine from your end that would not be ideal solution.

@iffyio
Copy link
Contributor

iffyio commented Oct 14, 2024

Hi @emilsivervik Sure! Could you take a look at the CLUSTERED INDEX impl which has similar syntax and likely solution for parsing and representing the (id ASC) type scenarios?
I'm thinking we'd probably be able to reuse that type, for example if we extend the IndexType parsing and representation to include:

pub enum IndexType {
    BTree(Option<Vec<ClusteredIndex>>),
    Hash(Option<Vec<ClusteredIndex>>),
}

And then something similar for the KEY support. Let me know if you have any questions.

Also, from the tests I'm assuming this is a mysql syntax? could you include a link to the docs maybe in the PR description where this syntax is described?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants