Add ability to add (define) composite index #88

socketpair opened this Issue Oct 25, 2014 · 1 comment


None yet

2 participants


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 from Add composite index creation to Add ability to add (define) composite index Oct 26, 2014
@kozlovsky kozlovsky self-assigned this Oct 28, 2014
@kozlovsky kozlovsky closed this in cfecb30 Oct 29, 2014

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