Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Add support for defining indexes on models#13

Open
soderluk wants to merge 6 commits into
ioxiocom:mainfrom
soderluk:ensure_indexes
Open

Add support for defining indexes on models#13
soderluk wants to merge 6 commits into
ioxiocom:mainfrom
soderluk:ensure_indexes

Conversation

@soderluk

@soderluk soderluk commented May 7, 2022

Copy link
Copy Markdown

Support ensuring indexes on collections. The Model.ensure_indexes()
function supports any indexing function that ArangoDB Collection
supports.

@lietu

lietu commented May 9, 2022

Copy link
Copy Markdown

Hey @soderluk ! 🙂

I think one way to tackle this a bit more cleanly would be to create classes for the different types of index, so HashIndex()? or AddHashIndex()? which take arguments, and you could then append them to a list instead of using magic string keys in a dict.

What do you think?

@lietu

lietu commented May 9, 2022

Copy link
Copy Markdown

So something like

indexes = [
  HashIndex(fields=["_from", "_to", "type"], unique=True)
]

@soderluk

soderluk commented May 9, 2022

Copy link
Copy Markdown
Author

@lietu Good idea! Will look into it :)

@soderluk

soderluk commented May 9, 2022

Copy link
Copy Markdown
Author

@lietu Made some updates to the PR. Please have a look, when you have the time.

Comment thread arangodantic/tests/test_model.py
@lietu

lietu commented May 9, 2022

Copy link
Copy Markdown

Overall I'd say I like it, with some luck @joakimnordling has the time to take a look at some point as well 👍

Comment thread arangodantic/indexes.py Outdated
Comment thread arangodantic/indexes.py Outdated
Comment thread arangodantic/indexes.py Outdated
Comment thread arangodantic/models.py Outdated
Comment thread arangodantic/tests/conftest.py
Comment thread arangodantic/tests/test_model.py
Support ensuring indexes on collections. The `Model.ensure_indexes()`
function supports any indexing function that ArangoDB Collection
supports.
Instead of using magic methods, set up index classes to handle all the
different indexing cases.
Mypy doesn't really understand what is returned from the add_*_index
function.
Fix the tests for ensuring indexes.

Make BaseIndex abstract base class, and make the add_index function as
abstract as well.

Move fields away from the BaseIndex to their respective sub-classes.
@soderluk

soderluk commented Nov 6, 2022

Copy link
Copy Markdown
Author

@joakimnordling Updated the tests and fixed a few things according to code review.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants