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 support for Index parsing #22

Closed
julioz opened this issue May 19, 2020 · 0 comments · Fixed by #41
Closed

Add support for Index parsing #22

julioz opened this issue May 19, 2020 · 0 comments · Fixed by #41
Labels
DBML Parser Work related to the DBML Parsing component enhancement New feature or request

Comments

@julioz
Copy link
Owner

julioz commented May 19, 2020

So far, dbml-parser doesn't properly handle indexes defined in DBML tables, as such:

Table bookings {
  id integer
  country varchar
  booking_date date
  created_at timestamp

  indexes {
      (id, country) [pk] // composite primary key
      created_at [note: 'Date']
      booking_date
      (country, booking_date) [unique]
      booking_date [type: hash]
      (`id*2`)
      (`id*3`,`getdate()`)
      (`id*3`,id)
  }
}

There are 3 types of index definitions:

Index with single field (with index name): CREATE INDEX on users (created_at)
Index with multiple fields (composite index): CREATE INDEX on users (created_at, country)
Index with an expression: CREATE INDEX ON films ( first_name + last_name )
(bonus) Composite index with expression: CREATE INDEX ON users ( country, (lower(name)) )

@julioz julioz added enhancement New feature or request help wanted labels May 19, 2020
@julioz julioz added the DBML Parser Work related to the DBML Parsing component label Jun 4, 2020
julioz added a commit that referenced this issue Jun 21, 2020
Fixes #22 

This adds support for basic definition of indexes in DBML `Table` constructs:
```
Indexes {
  (<column names>) [name: '<index name>', <uniqueness>]
}
```

More advanced use-cases (i.e: no name indexes, expression-based indexes) are unsupported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DBML Parser Work related to the DBML Parsing component enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant