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

Unique Constaints on multiple fields #248

Open
ilyatbn opened this issue May 21, 2023 · 1 comment
Open

Unique Constaints on multiple fields #248

ilyatbn opened this issue May 21, 2023 · 1 comment
Assignees
Labels
community community Effort - Medium Effort - Medium feature feature Frequency - Monthly Frequency - Monthly Priority - Later Priority - Later Reach - VeryFew Reach - VeryFew Severity - S3 Severity - S3

Comments

@ilyatbn
Copy link

ilyatbn commented May 21, 2023

considering the following Node class:

class DataSet(Node):
    id: str = Field(exists=True, db=connection)
    item_type: str = Field(exists=True, db=connection)
    ...

How do I make a unique constaint for both fields using the Node class?

I can achieve this manually by adding the following outside of the class:

connection.create_constraint(MemgraphConstraintUnique(label='DataSet', property=('id', 'item_type')))

If I set each field with a unique=True property the constraint is created separately for each field and I only want them to both be the same to be considered unique.

@katarinasupe
Copy link
Contributor

Hi @ilyatbn, thank you for reporting this. It is impossible to specify multiple properties when creating uniqueness constraints by extending Node class. But I can see you managed to find the workaround! Thank you for pointing this out! I will leave this issue open so we can plan to add it as a feature. You are also more than welcome to contribute!

What are you working on?

@katarinasupe katarinasupe added the type: enhancement New feature or request label May 23, 2023
@katarinasupe katarinasupe added this to the v1.5.0 milestone May 23, 2023
@katarinasupe katarinasupe removed this from the v1.5.0 milestone Sep 15, 2023
@katarinasupe katarinasupe added Importance - I3 Importance - I3 Severity - S3 Severity - S3 Effort - Medium Effort - Medium feature feature community community and removed type: enhancement New feature or request labels Dec 28, 2023
@hal-eisen-MG hal-eisen-MG added Priority - Later Priority - Later and removed Priority - Later Priority - Later labels Feb 4, 2024
@hal-eisen-MG hal-eisen-MG added Priority - Later Priority - Later and removed Priority - Later Priority - Later labels Feb 18, 2024
@katarinasupe katarinasupe added Frequency - Monthly Frequency - Monthly Reach - VeryFew Reach - VeryFew and removed Importance - I3 Importance - I3 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community Effort - Medium Effort - Medium feature feature Frequency - Monthly Frequency - Monthly Priority - Later Priority - Later Reach - VeryFew Reach - VeryFew Severity - S3 Severity - S3
Projects
Status: Todo
Development

No branches or pull requests

5 participants