Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.75k stars 106 forks source link

partial_unchecked extend #334

Closed tingfeng-key closed 1 year ago

tingfeng-key commented 1 year ago

For example, I have a CreateParams as follows:

system_user::partial_unchecked!(CreateParams {
    nickname
    role_id
    dept_id
    phone
    email
    sex
    password
    salt
    describe
    expire_time
    status
});

Then I need to add a username field when updating, so I need to copy CreateParams. Is it possible to expand on the basis of CreateParams, such as this:

system_user::partial_unchecked_extend!(CreateParams,UpdateParams {
    username
});

UpdateParams is now as follows:

system_user::partial_unchecked!(UpdateParams {
    username
    nickname
    role_id
    dept_id
    phone
    email
    sex
    password
    salt
    describe
    expire_time
    status
});
Brendonovich commented 1 year ago

This is probably possible by making partial_unchecked emit its own macro_rules that can construct CreateParams from UpdateParams, but I feel like it's just not worth it compared to how much effort it would take. Besides, I don't thinkCreateParams and UpdateParams will be interchangeable in 0.7.0 anyway.

tingfeng-key commented 1 year ago

ok, that would be really cool if it came to fruition one day

Brendonovich commented 1 year ago

CreateParams and UpdateParams definitely aren't going to be compatible with each other in future, plus doing this would be wayyy to much overhead for me to maintain.

tingfeng-key commented 1 year ago

Understood, thank you for your reply. I will close it