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

RowValue derive macro #51

Merged
merged 2 commits into from
Feb 28, 2022
Merged

RowValue derive macro #51

merged 2 commits into from
Feb 28, 2022

Conversation

nothingelsematters
Copy link
Contributor

@nothingelsematters nothingelsematters commented Feb 15, 2022

This is our solution for #49. It contains a new derive crate with a RowValue derive macro.

A macro usage example:

#[derive(RowValue)]
struct TestStruct {
    #[row_value(rename = "fifth")]
    first: String,
    second: i64,
    #[row_value(with = "some::path::custom_big_decimal_parser")]
    third: BigDecimal,
    fourth: Option<String>,
}

This would expand into an oracle::RowValue implementation which constructs a structure as follows:

TestStruct {
    first: row.get("fifth")?,
    second: row.get("second")?,
    third: some::path::custom_big_decimal_parser(row, "third")?,
    fourth: row.get("fourth")?,
}

@kubo
Copy link
Owner

kubo commented Feb 21, 2022

@nothingelsematters
Thanks for making pull request.

Could you change as follows?

  1. Rename the crate name from rust-oracle-derive to oracle_procmacro.
    The crate name of rust-oracle is oracle. So the name of the new crate should be similar.
    In addition the crate may contain not only derive macros but also other procedural macros in future.
  2. Add [workspace] and an empty line as follows at the top of Cargo.toml at the top level directory.
    [workspace]
    
    [package]
    name = "oracle"
    ...
    
    In https://doc.rust-lang.org/cargo/reference/workspaces.html:

    An empty [workspace] table can be used with a [package] to conveniently create a workspace with the package and all of its path dependencies.

@kubo kubo merged commit bda8440 into kubo:master Feb 28, 2022
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.

2 participants