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

fix(psl): composite type validation in indices #4401

Merged
merged 9 commits into from
Nov 9, 2023

Conversation

Druue
Copy link
Contributor

@Druue Druue commented Nov 1, 2023

Updated the composite type validation introduced here to only throw a validation error when encountering composite types in compound indices.
(Specifically unique indices as I can't reproduce this using either normal or fulltext indices)

fixes prisma/prisma#21441
contributes prisma/prisma#21723

related discovery page: notion

@Druue Druue added this to the 5.6.0 milestone Nov 1, 2023
@Druue Druue requested a review from a team as a code owner November 1, 2023 02:44
@Druue Druue requested review from miguelff and jkomyno and removed request for a team November 1, 2023 02:44
Copy link

codspeed-hq bot commented Nov 1, 2023

CodSpeed Performance Report

Merging #4401 will not alter performance

Comparing fix/composites_compound_index (a58ad02) with main (f9e46ef)

Summary

✅ 11 untouched benchmarks

@Druue Druue force-pushed the fix/composites_compound_index branch from afeaee9 to e3f1ca5 Compare November 1, 2023 14:46
@Druue Druue removed their assignment Nov 1, 2023
@@ -123,7 +123,7 @@ pub(super) fn validate(ctx: &mut Context<'_>) {
indexes::supports_clustering_setting(index, ctx);
indexes::clustering_can_be_defined_only_once(index, ctx);
indexes::opclasses_are_not_allowed_with_other_than_normal_indices(index, ctx);
indexes::composite_types_are_not_allowed_in_index(index, ctx);
indexes::composite_type_in_compound_unique_index(index, ctx);
Copy link
Member

Choose a reason for hiding this comment

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

What about normal indexes? Are those supported with a mix of scalar and composite fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They don't actually hit this error (fulltext also doesn't). Not to say they're supported but they run into different issues that are unrelated to the original crash report. Only @@unique causes a panic from what I've found

Copy link
Contributor

@miguelff miguelff left a comment

Choose a reason for hiding this comment

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

I don't see anything particularly wrong, I only had a question about non-composite indexes, but Jan made it before and you replied already. So the changes look good to me, given the test cases you implemented.

@@ -91,7 +91,7 @@ impl ScalarField {

match scalar_field_type {
ScalarFieldType::CompositeType(_) => {
unreachable!("Cannot convert a composite type to a type identifier. This error is typically caused by mistakenly using a composite type within a composite index.",)
unreachable!("This shouldn't be reached; composite types are not supported in compound unique indices.",)
Copy link
Contributor

Choose a reason for hiding this comment

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

Less cryptic message 👍🏾

group String
}
#[test]
fn converting_composite_types_compound_unique() {
Copy link
Contributor

Choose a reason for hiding this comment

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

💯 to the exhaustive tests

Add test to validate `@@index` case
@Druue Druue force-pushed the fix/composites_compound_index branch from 7d1b385 to a58ad02 Compare November 9, 2023 18:32
@Druue Druue merged commit d5d315c into main Nov 9, 2023
54 of 58 checks passed
@Druue Druue deleted the fix/composites_compound_index branch November 9, 2023 22:46
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.

Regression for MongoDB introspection in 5.4.0
3 participants