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

core: Sort constraint definitions before comparing #727

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

kim
Copy link
Contributor

@kim kim commented Jan 17, 2024

When updating a database, we may falsely report schemas as not
compatible due to the ConstraintDefs coming out in different orders in
the proposed and existing schemas.

Not sorting them was an oversight in 9bb2b21.

Expected complexity level and risk

1

When updating a database, we may falsely report schemas as not
compatible due to the `ConstraintDef`s coming out in different orders in
the proposed and existing schemas.

Not sorting them was an oversight in 9bb2b21.
Copy link
Collaborator

@kurtismullins kurtismullins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kim I am going to stamp this but won't pretend to understand the difference :) May I steal some of your time soon to get a walk-through of the code that gives some context? I've been meaning to ask you, anyways :)

.filter(|c| c.constraints != Constraints::unset())
.collect()
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be better to do this change inside TableDef?:

pub struct TableDef {
    pub table_name: String,

    pub constraints: BtreeSet<ConstraintDef>,
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually want to store them like that? We might just want this function as a way to compare them. I think I'm going to propose that we merge this and consider that for future work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It threw me off a bit to realize that there can be unset constraints in the table def, so we would still need an element-wise comparison if it was a set already.

Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM

.filter(|c| c.constraints != Constraints::unset())
.collect()
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually want to store them like that? We might just want this function as a way to compare them. I think I'm going to propose that we merge this and consider that for future work.

@kim kim added this pull request to the merge queue Jan 18, 2024
Merged via the queue into master with commit 9441409 Jan 18, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

4 participants