- Notifications
You must be signed in to change notification settings - Fork516
Add support for money type#601
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Add support for money type#601
Uh oh!
There was an error while loading.Please reload this page.
Conversation
9b69b5a
tod24167e
CompareFor a postgres-specific crate like postgres_money, these impls would just live directly in that crate and not require a feature over here. |
tkbrigham commentedMay 9, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@sfackler the The pattern I believe you are suggesting is keep all of the impls in the postgres_money crate, but that seems to lead to the following situation:
This seems to fly in the face of encapsulation, where this crate now has to have knowledge of its consumers, instead of the consumers taking a dependency on this crate. It seems that unless every crate that interfaces with Postgres data directly has the same APIs and signatures, implementing the SQL representation traits for As a concrete example, if we pretend Diesel didn't have theMoney type support in place, they could take a dependency on So it seems like the SQL-interface layer is better served as a feature within the crates that access Postgres, not within the generic representation of that data. |
arekbal commentedMay 9, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Don't blame me if I am wrong(a noob here) but isn't postgres_money meant to be more like sattelite crate - an extension for main postgres crates instead? Not like let-everybody-in club.
|
This does not appear to have been a problem in the last 5 or so years of the development of this crate. |
You can always have a feature flat on postgres_money to make the dependency on postgres_types optional. |
If I were someone new coming to the rust-postgres crate and I wanted support for both the If the goal is to have developers choose their own implementation because |
I don't understand - you have to use an external implementation of the |
tkbrigham commentedMay 9, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think the drivers for my thought process are basically three things, broken down intouser concerns (devs using the rust-postgres crate) andmaintainer concerns (e.g. you for rust-postgres and me for postgres_money): User ConcernsDiscoverabilityAs a developer, I decide to us PG as a backend. I discover this crate, and pull it in as a dep. I know I have some tables that will depend on Possible outcomes:
Of note: this was basically the process I went through when I realized there was no Robust Postgres SupportThis crate says You mentioned this hasn't been a concern with other crates - can you give me examples of other crates that implement Postgres native types and also implement rust-postgres ToSql and FromSql impls? Maintainer ConcernsMaintainabilityIf your concern is to avoid adding more dependencies to the rust-postgres footprint, or concerns with being the one responsible to maintain the ToSql and FromSql implementations for the |
No, you enable the feature on the postgres dependency and add the dependency on the postgres_money crate. How is that significantly different from adding a dependency on the postgres_money crate and (maybe) enabling a feature on the postgres_money crate? |
tkbrigham commentedMay 11, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Because of discoverability. The developer has already found the On the other hand, if support for This is all in addition to the fact that I'm having a hard time understanding your motivations and responses from the feedback you are providing. Perhaps you could share what your goals are for suggesting this live outside of rust-postgres, or what you are optimizing for generally? If you do, I could help address those concerns or understand why my suggested approach is not preferable. |
The docs can point people towards postgres-money.
I want to minimize the number of feature flags exposed by the postgres crate. If a library is built specifically for postgres, like postgres-array, or postgres-range, or postgres-money, then that's great since a feature flag won't be necessary for those types. I want to avoid having types with nontrivial APIs (like ranges or arrays or money) in this crate. That allows those APIs to have more freedom to iterate through e.g. breaking changes. I do not want to cut breaking releases of the core postgres crates very often since each break pushes work downstream to update. |
@sfackler understood. The minimization of feature flags is definitely not what I'd expected, so that is good to know. I will close this PR. I'd probably lean towards keeping the issue open, but I'll defer to you on that. |
nixpulvis commentedMay 8, 2022
Both |
This _does not_ add the date window support, yet. This is because thereis not a great native rust-postgres way of getting PostgreSQLs DATERANGEtype. Looks like there'srust-postgres/rust-postgres-range#18, but it hasn'tbeen merged in a year and the general state of rust-postgres-range seemsunmaintained.. perhaps@tkbrigham has a good point inrust-postgres/rust-postgres#601.. it'd be great if all the PostgreSQLfeatures were supported in rust-postgres directly.
This _does not_ add the date window support, yet. This is because thereis not a great native rust-postgres way of getting PostgreSQLs DATERANGEtype. Looks like there'srust-postgres/rust-postgres-range#18, but it hasn'tbeen merged in a year and the general state of rust-postgres-range seemsunmaintained.. perhaps@tkbrigham has a good point inrust-postgres/rust-postgres#601.. it'd be great if all the PostgreSQLfeatures were supported in rust-postgres directly.
This _does not_ add the date window support, yet. This is because thereis not a great native rust-postgres way of getting PostgreSQLs DATERANGEtype. Looks like there'srust-postgres/rust-postgres-range#18, but it hasn'tbeen merged in a year and the general state of rust-postgres-range seemsunmaintained.. perhaps@tkbrigham has a good point inrust-postgres/rust-postgres#601.. it'd be great if all the PostgreSQLfeatures were supported in rust-postgres directly.
This _does not_ add the date window support, yet. This is because thereis not a great native rust-postgres way of getting PostgreSQLs DATERANGEtype. Looks like there'srust-postgres/rust-postgres-range#18, but it hasn'tbeen merged in a year and the general state of rust-postgres-range seemsunmaintained.. perhaps@tkbrigham has a good point inrust-postgres/rust-postgres#601.. it'd be great if all the PostgreSQLfeatures were supported in rust-postgres directly.
Closes#598
Implements
ToSql
andFromSql
for thepostgres_money::Money
struct, behind the featurewith-money-0_2
.