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

Add support for UUIDv7 #4877

Merged
merged 4 commits into from
Aug 1, 2024
Merged

Add support for UUIDv7 #4877

merged 4 commits into from
Aug 1, 2024

Conversation

mcuelenaere
Copy link
Contributor

@mcuelenaere mcuelenaere commented May 20, 2024

This implements prisma/prisma#24079. The change is pretty minimal, widening the support from @default(uuid()) to @default(uuid(7)).

It leverages the existing uuid crate instead of adding a new one (uuid7).

Right now this code is mostly untested (apart from the tests I added to psl), because I couldn't get the tests running locally. I'd appreciate some guidance in this area. CI runs fine

@mcuelenaere mcuelenaere requested a review from a team as a code owner May 20, 2024 12:14
@mcuelenaere mcuelenaere requested review from jkomyno and removed request for a team May 20, 2024 12:14
@CLAassistant
Copy link

CLAassistant commented May 20, 2024

CLA assistant check
All committers have signed the CLA.

@kibertoad
Copy link

uuid seems to be behind uuid7 with regards to how accurately it represents the spec. See discussion here: uuid-rs/uuid#717

@SevInf SevInf removed the request for review from jkomyno May 21, 2024 08:36
Copy link

codspeed-hq bot commented May 21, 2024

CodSpeed Performance Report

Merging #4877 will not alter performance

Comparing mcuelenaere:feature/uuidv7 (81642e5) with main (34ace0e)

Summary

✅ 11 untouched benchmarks

@mcuelenaere
Copy link
Contributor Author

FYI: after this gets an approval, I'll rebase + squash the fixup commits

@kibertoad
Copy link

@Weakky Gentle ping. Is anything missing in this PR?

Copy link
Contributor

@Weakky Weakky left a comment

Choose a reason for hiding this comment

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

Apologies for the delayed review and thanks for the quality work @mcuelenaere. Would you mind adding a query-engine test that uses uuid(7) and:

  • create a row with it
  • reads it from findMany
  • reads it from findUnique

You could add this test in this file: query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/ids/uuid_create_graphql.rs

@Weakky
Copy link
Contributor

Weakky commented Jun 24, 2024

@mcuelenaere Thanks for the quick review fix. I have run the tests. Would you mind having a look at the failures?

@mcuelenaere
Copy link
Contributor Author

@Weakky I am able to run the tests for sqlite locally, but they seem to fail in CI for the driver adapters. However, I can't seem to easily run these locally + the output of the CI does not give any indication as to what's going wrong (just that it's failing).

Any help would be appreciated.

@xiaolongkipsi
Copy link

follow

@mcuelenaere
Copy link
Contributor Author

I've rebased on current main, as that seems stable and the tests were failing due to something else the last time

@mcuelenaere
Copy link
Contributor Author

I've also updated uuid to v1.10.0 to address @kibertoad 's comment

@kibertoad
Copy link

@Weakky Is there anything missing?

@Weakky
Copy link
Contributor

Weakky commented Jul 31, 2024

@mcuelenaere I have investigated why tests were failing. Turns out SystemTime::now is not implemented yet for Wasm. rust-lang/rust#48564

Fortunately, uuid has a "js" feature which works around this limitation.

https://github.com/uuid-rs/uuid/blob/main/src/timestamp.rs#L302-L327

Could you please add the "js" feature for the uuid crate?

Thanks

@mcuelenaere
Copy link
Contributor Author

mcuelenaere commented Jul 31, 2024

Aha, good catch! I've pushed a fixup commit for that.

I assume just straight-up adding the feature to uuid is fine and it does not need to be in some kind of [target.'cfg(target_arch = "wasm32")'.dependencies] context, right?

@Weakky Weakky added this to the 5.18.0 milestone Aug 1, 2024
Copy link
Contributor

@Weakky Weakky left a comment

Choose a reason for hiding this comment

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

Apologies again for the long delay to get this point. This looks good now. Great work, thanks a lot for the contribution. LGTM 🙏

@@ -52,7 +52,7 @@ tokio = { version = "1.25", features = [
] }
chrono = { version = "0.4.38", features = ["serde"] }
user-facing-errors = { path = "./libs/user-facing-errors" }
uuid = { version = "1", features = ["serde", "v4"] }
uuid = { version = "1", features = ["serde", "v4", "v7", "js"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

@mcuelenaere Yes, that's fine this way.

@Weakky Weakky merged commit 4c784e3 into prisma:main Aug 1, 2024
366 of 367 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.

5 participants