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

Allow (autogenerated) Int8 id values #5029

Merged
merged 3 commits into from
Dec 4, 2023
Merged

Allow (autogenerated) Int8 id values #5029

merged 3 commits into from
Dec 4, 2023

Conversation

lutter
Copy link
Collaborator

@lutter lutter commented Nov 29, 2023

With this change, it is possible to use Int8 as the type of an entity's id. In addition, when store.set is called with the id argument set to "auto", an id is auto-generated (see the comment on IdType::generate_id for details)

Auto-generation is also possible if the type of id is Bytes

For now, this is really only useful for immutable entities as it's not possible to find out what the id was set to from the mappings; we should address that in a future PR.

Fixes #5018

@lutter lutter force-pushed the lutter/int8 branch 6 times, most recently from fd56c20 to b410030 Compare November 29, 2023 18:29
@@ -624,6 +624,7 @@ fn id_type_as_scalar(
}?;
let scalar_type = id_type.map(|id_type| match id_type {
IdType::String | IdType::Bytes => ScalarType::new(String::from("String")),
IdType::Int8 => ScalarType::new(String::from("Int")),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be "Int8"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch, and a fun way to spend a few hours why this works with Int but not with Int8 - the upshot is that Int8 gets treated as a string internally in too many places, and queries just blow up in that case. Addressing that is a little scary and I've opened the separate PR #5034 to do that.

For this PR, I just left a big comment why it's Int and not Int8 for now.

@lutter lutter merged commit 91e8eed into master Dec 4, 2023
@lutter lutter deleted the lutter/int8 branch December 4, 2023 18:56
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.

[Feature] Auto-incrementing ids
3 participants