-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 support for PostgreSQL HSTORE data type #3343
Add support for PostgreSQL HSTORE data type #3343
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd at least like to start with something that gives us more room to evolve the API later (this also makes it clear that the expected SQL type is hstore
):
pub struct PgHStore(pub BTreeMap<String, Option<String>>);
impl Deref for PgHStore {
type Target = BTreeMap<String, Option<String>>;
...
}
impl DerefMut for PgHStore {
...
}
impl FromIterator<(String, String)> for PgHStore { ... }
impl FromIterator<(String, Option<String>)> for PgHStore { ... }
impl IntoIterator for PgHStore {
type Iterator = btree_map::IntoIter<(String, Option<String>)>;
...
}
With this, we could add a defaulted type parameter, e.g. T = BTreeMap<String, Option<String>>
to allow the use of other types without breaking existing usage (for the most part, anyway). I was thinking if we used serde::Deserialize
and serde::Serialize
, the user could use any map type they wanted, or even a struct.
* Add support for PostgreSQL HSTORE data type * Changes to make the future evolution of the API easier * Fix clippy lints * Add basic documentation
* Add support for PostgreSQL HSTORE data type * Changes to make the future evolution of the API easier * Fix clippy lints * Add basic documentation
Adds support for postgres hstore data type by mapping it to a BTreeMap<String, Option>. Using a BTreeMap rather than a HashMap ensures that the keys remain sorted. This is helpful for auto generated history data. Previously discussed as #151.