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 ability to add (define) composite index #88

Closed
socketpair opened this issue Oct 25, 2014 · 1 comment
Closed

Add ability to add (define) composite index #88

socketpair opened this issue Oct 25, 2014 · 1 comment
Assignees

Comments

@socketpair
Copy link

Today, you have composite_key -> add UNIQUE check to the table. I did not found in documentation how I can create composite index, which allows duplicate values and allows effective range queries, which is not true for unique checks.

@socketpair socketpair changed the title Add composite index creation Add ability to add (define) composite index Oct 26, 2014
@kozlovsky kozlovsky self-assigned this Oct 28, 2014
@kozlovsky
Copy link
Member

I added composite_index() which works the same way as composite_key(), but defines non-unique index instead:

class Person(db.Entity):
    id = PrimaryKey(int, auto=True)  # primary key
    passport_id = Required(str, unique=True)  # simple unique index
    name = Required(unicode, index=True)  # simple non-unique index
    age = Required(int)
    composite_key(name, age)  # unique composite index
    composite_index(age, name)  # non-unique composite index

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

No branches or pull requests

2 participants