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

Very WIP: Custom Postgres Types in Macros #336

Closed
wants to merge 15 commits into from

Conversation

phated
Copy link
Contributor

@phated phated commented May 25, 2020

As @abonander mentioned in #313, his ab/offline branch has laid the groundwork for working on custom type support in postgres.

I know this draft has my custom types and their hardcoded oids, but I really need custom type support in macros, so I've been hacking around in the project a bit.

If I'm on the right track to adding full support for custom types, I'm happy to keep trying to implement them with some guidance.

If I'm completely off-track, we can close this and I will build against my branch until the feature gets finished.

Keep up the great work! 🍻

@mehcode
Copy link
Member

mehcode commented Jun 10, 2020

First I want to say that I didn't mean to close this without a note. Apolgoies.

After skimming your PR, you have the basic idea. A discussion point is how does the user add stuff to "get-custom-types"? We're currently leaning towards a sqlx.toml file where you declare type mappings
of "SQL type name" to "full Rust type path".

If you get around to rebasing this for personal usage or to try and move along this task on SQLx, note that you want to declare your custom types with PgTypeInfo::with_name("dfsdsf") or PgTypeInfo(PgType::DeclareWithName("dsfsdf")). This will cause SQLx to resolve the OID at runtime (and cache it).


Unfortunately this would only help Postgres (as other databases have column local types not types as first class objects) so we've placed this after #339 in order of priority.

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.

3 participants