-
Notifications
You must be signed in to change notification settings - Fork 28
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 option to export model keys #220
Comments
This adds an optional `export_keys` bool param to the `native_db` proc macro that controls the visibility of the model's secondary key enum. Default value is `false`, which matches the existing behaviour of setting the visibility of the secondary key enum to `pub(crate)`. Using `#[native_db(export_keys = true)]` changes this to `pub`. See vincent-herlemont#220 for discussion.
This adds an optional `export_keys` bool param to the `native_db` proc macro that controls the visibility of the model's secondary key enum. Default value is `false`, which matches the existing behaviour of setting the visibility of the secondary key enum to `pub(crate)`. Using `#[native_db(export_keys = true)]` changes this to `pub`. See vincent-herlemont#220 for discussion.
You can see my proposed impl here: main...Grimeh:export_keys I added a rudimentary "does this compile with I'll open a PR if it looks good after some testing. |
Thank you very much, @Grimeh that's a great idea! You can submit your PR. |
I am closing this issue for now because there is no short-term need in the roadmap, but it will be reopened if needed. Note: However, a PR is always welcome. |
Sorry for the delay, just wrapped up a contract that took most of my time. |
This adds an optional `export_keys` bool param to the `native_db` proc macro that controls the visibility of the model's secondary key enum. Default value is `false`, which matches the existing behaviour of setting the visibility of the secondary key enum to `pub(crate)`. Using `#[native_db(export_keys = true)]` changes this to `pub`. See vincent-herlemont#220 for discussion.
This adds an optional `export_keys` bool param to the `native_db` proc macro that controls the visibility of the model's secondary key enum. Default value is `false`, which matches the existing behaviour of setting the visibility of the secondary key enum to `pub(crate)`. Using `#[native_db(export_keys = true)]` changes this to `pub`. See vincent-herlemont#220 for discussion.
Thank you for your PR and your work @Grimeh. Consequently, I am placing this issue on the roadmap for 0.8.0. |
This adds an optional `export_keys` bool param to the `native_db` proc macro that controls the visibility of the model's secondary key enum. Default value is `false`, which matches the existing behaviour of setting the visibility of the secondary key enum to `pub(crate)`. Using `#[native_db(export_keys = true)]` changes this to `pub`. See #220 for discussion.
This adds an optional `export_keys` bool param to the `native_db` proc macro that controls the visibility of the model's secondary key enum. Default value is `false`, which matches the existing behaviour of setting the visibility of the secondary key enum to `pub(crate)`. Using `#[native_db(export_keys = true)]` changes this to `pub`. See #220 for discussion.
This adds an optional `export_keys` bool param to the `native_db` proc macro that controls the visibility of the model's secondary key enum. Default value is `false`, which matches the existing behaviour of setting the visibility of the secondary key enum to `pub(crate)`. Using `#[native_db(export_keys = true)]` changes this to `pub`. See #220 for discussion.
I'm restructuring my project and have noticed that model keys are defined with
pub(crate)
visibility.I can see the motivation for this choice and generally agree with it. However it would be helpful to have the ability to make them
pub
for access from sibling crates.From a quick look (and my limited experience with proc macros) it seems like it wouldn't be too difficult to add a parameter to the
native_db
macro to enable something like:Then
pub(crate) enum #keys_enum_name
fromnative_db.rs:59
could be changed to something like#keys_visibility enum #keys_enum_name
.native_db/native_db_macro/src/native_db.rs
Lines 59 to 61 in 50063a0
I'm going to make a fork to try this out for my own purposes, would you be keen on this change if I opened a PR?
The text was updated successfully, but these errors were encountered: