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

GlobalSecondaryIndex + Polymorphism #1192

Open
ynie opened this issue Aug 5, 2023 · 0 comments
Open

GlobalSecondaryIndex + Polymorphism #1192

ynie opened this issue Aug 5, 2023 · 0 comments

Comments

@ynie
Copy link

ynie commented Aug 5, 2023

Hey all, I'm new to pynamoDB. Here is my setup

class DateIndex(GlobalSecondaryIndex):
    class Meta:
        projection = AllProjection()
    data_type = UnicodeAttribute(hash_key=True)

class CredentialBase(Model):
    id = UnicodeAttribute(hash_key=True)
    date_index = DataTypeDateIndex()
    cls = DiscriminatorAttribute()

class Credential(CredentialBase, discriminator='Credential"):
    class Meta:
        table_name = ""

Why wouldn't this work?
results = Credential.date_index.query("", limit=1)

It tries to look up the dateIndex on CredentialBase instead of Credential. I can fix the problem by moving the date_index to the childClass Credential. Is that the correct way of doing it? Thanks!

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

1 participant