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

Support Postgres network types (inet) #888

Open
001wwang opened this issue Jul 18, 2022 · 10 comments
Open

Support Postgres network types (inet) #888

001wwang opened this issue Jul 18, 2022 · 10 comments

Comments

@001wwang
Copy link

Motivation

I would like to use Postgres network types (i.e. inet) in my Model definitions. I understand there may be workarounds, so this is not urgent but would be a quality-of-life improvement.

Proposed Solutions

I believe this is nearly/already supported in sea-query: SeaQL/sea-query#187. From my understanding, supporting this in sea-orm requires updating the logic that converts a query result into an instance of a Model: perhaps here.

Additional Information

Currently, attempts to use inet will result in a runtime error.

@billy1624
Copy link
Member

Hey @001wwang, sorry for the delay. Network types are supported on SeaQuery, however, it's only supported by PostgreSQL but not by MySQL and SQLite.

So, the questions was do we want to bring the network types support to SeaORM for PostgreSQL only? Or, support it for MySQL and SQLite as well. We can simply serialize network types as string for MySQL and SQLite.

Thoughts?

CC @tyt2y3

@001wwang
Copy link
Author

No worries at all, this is not a blocker for us. We only use PostgreSQL so I'll hold off on any judgement for MySQL and SQLite. Thanks for the context.

@ikrivosheev
Copy link
Member

@billy1624 I think support network types only for PostgreSQL (for example SqlAlchemy, python ORM, support it only for PostgreSQL).

@ikrivosheev
Copy link
Member

@tyt2y3 @billy1624 if it's, I can prepare PR)

@tyt2y3
Copy link
Member

tyt2y3 commented Aug 7, 2022

Let me think about it

@billy1624
Copy link
Member

Any updates? @tyt2y3

@hut8
Copy link
Contributor

hut8 commented Nov 28, 2022

I would like this feature! Question about implementation: to what Rust type would inet map? std::net::IpAddr seems like a logical choice, but Postgres's inet type also can contain the subnet. So I guess we would have to just discard that, right? Is there a better type?

@Razican
Copy link

Razican commented Nov 28, 2022

One option would be ipnetwork, which is already supported by SQLx (and diesel), but it's not stable, and SQLx itself is not able keep the version up to date: launchbadge/sqlx#2148

Another option is ipnet, which has a stable API, many downloads and updates, and it's supported by diesel too, for example.

@holmofy
Copy link

holmofy commented Aug 31, 2023

What is the current progress on this issue? I found that sqlx already provides inet type support for postgresql :https://github.com/launchbadge/sqlx/blob/main/sqlx-postgres/src/types/ipnetwork.rs

@tyt2y3 tyt2y3 removed the good first issue Good for newcomers label Sep 1, 2023
@tyt2y3
Copy link
Member

tyt2y3 commented Sep 1, 2023

The issue is still outstanding. No concrete plan for it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

7 participants