sea-query icon indicating copy to clipboard operation
sea-query copied to clipboard

PostgreSQL ipaddr/cidr/macaddress

Open ajf opened this issue 3 years ago • 6 comments

It would be great to see support for the postgres types for inet/cidr/macaddr/macaddr8

https://www.postgresql.org/docs/14/datatype-net-types.html

I was poking at this but I have a few questions:

These data types are only built-in on PostgreSQL and appear to be supported by sqlx features ipnetwork, mac_address. I assume I have to add features to sea-query and sea-orm. I'm mainly just following the code for uuid.

Next, what's the general handling of sqllite / mysql databases that doesn't handle this type? Should we ignore it or try to serialize/deserialize to varchar or 32/48/128-bit integers?

postgres-types, a dependency of sea-query uses eui48, while sqlx uses mac_address to provide mac addresses. What relation does sea-query have to sqlx? I don't see any sqlx dependency in the query crate, but the ORM crate has a dependency on both sea-query and sqlx.

ajf avatar Nov 16 '21 00:11 ajf

These data types are only built-in on PostgreSQL and appear to be supported by sqlx features ipnetwork, mac_address. I assume I have to add features to sea-query and sea-orm. I'm mainly just following the code for uuid.

Yes!

Next, what's the general handling of sqllite / mysql databases that doesn't handle this type? Should we ignore it or try to serialize/deserialize to varchar or 32/48/128-bit integers?

Serializing it to varchar (string) will be reasonable.

postgres-types, a dependency of sea-query uses eui48, while sqlx uses mac_address to provide mac addresses. What relation does sea-query have to sqlx? I don't see any sqlx dependency in the query crate, but the ORM crate has a dependency on both sea-query and sqlx.

Basically sea-query expose bind_params_sqlx_* macros for binding query & parameters generated by sea-query into SQLx query. So, sea-query doesn't requires any SQLx dependency.

billy1624 avatar Nov 16 '21 04:11 billy1624

@ajf @billy1624 I want to implement this if no one minds)

ikrivosheev avatar Apr 05 '22 18:04 ikrivosheev

@ikrivosheev I have not started any work, feel free!

ajf avatar Apr 13 '22 16:04 ajf

Thanks!! @ikrivosheev @ajf

billy1624 avatar Apr 21 '22 11:04 billy1624

I am working on PR.

ikrivosheev avatar Apr 21 '22 11:04 ikrivosheev

https://github.com/SeaQL/sea-query/pull/309 - add support for sqlx. it remains to add support for postgres-types

ikrivosheev avatar Apr 26 '22 17:04 ikrivosheev

Done: https://github.com/SeaQL/sea-query/pull/503

ikrivosheev avatar Nov 08 '22 09:11 ikrivosheev