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

diesel_derives: specify derive_from_sql_row() docs #4015

Merged

Conversation

bachmannscode
Copy link
Contributor

@bachmannscode bachmannscode commented May 6, 2024

This change addresses a terminology detail that may slightly mislead
some library users. The current doc comment states that this derive
implements Queryable for primitive types. "Primitive type" in that
context is supposed to refer to a rust type that corresponds to a
single SQL type in contrast to a whole database row.

However, the current term unfortunately collides with Rust's definition
of "primitive types" [1] so we phrase it in a slightly more elaborate
way to prevent confusion.

[1] https://doc.rust-lang.org/rust-by-example/primitives.html

@weiznich weiznich requested a review from a team May 6, 2024 16:29
@weiznich
Copy link
Member

weiznich commented May 7, 2024

Thanks for opening this PR. I agree with you that "primitive type" could refer to the wrong thing there, but I fear that "newtype struct" is even more incorrect as the derive can also be used on different rust types like enums or struct (for representing a sql record type or jsonb type).

@bachmannscode
Copy link
Contributor Author

Thanks for opening this PR. I agree with you that "primitive type" could refer to the wrong thing there, but I fear that "newtype struct" is even more incorrect as the derive can also be used on different rust types like enums or struct (for representing a sql record type or jsonb type).

Thank you for the review. True, I totally missed that. Do you think one of those could improve the docs:

Implements `Queryable` for types that correspond to a single SQL type. The type has to implement `FromSql`.

or

Implements `Queryable` for types that correspond to a single SQL type (for ones that implement `FromSql`).

?

@weiznich
Copy link
Member

I think the first variant sounds better.

This change addresses a terminology detail that may slightly mislead
some library users. The current doc comment states that this derive
implements `Queryable` for primitive types. "Primitive type" in that
context is supposed to refer to a rust type that corresponds to a
single SQL type in contrast to a whole database row.

However, the current term unfortunately collides with Rust's definition
of "primitive types" [1] so we phrase it in a slightly more elaborate
way to prevent confusion.

[1] https://doc.rust-lang.org/rust-by-example/primitives.html
@bachmannscode bachmannscode force-pushed the specify_fromsqlrow_derive_docs branch from 073180a to 20d9155 Compare May 19, 2024 11:46
@bachmannscode
Copy link
Contributor Author

I think the first variant sounds better.

Ack, done.

@weiznich
Copy link
Member

Thanks 👍

@weiznich weiznich added this pull request to the merge queue May 19, 2024
@bachmannscode
Copy link
Contributor Author

Thank you 💪

Merged via the queue into diesel-rs:master with commit c39a93b May 19, 2024
48 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.

None yet

2 participants