From 7c3eb65a69175f77d8eb9812b389ef9a099dfefe Mon Sep 17 00:00:00 2001 From: Beau Gieskens Date: Tue, 28 Jan 2025 08:00:41 +1000 Subject: [PATCH] feat: add ipnet support (#2150) --- Cargo.lock | 8 ++ Cargo.toml | 4 +- README.md | 2 + sqlx-core/Cargo.toml | 1 + sqlx-core/src/types/mod.rs | 7 + sqlx-macros-core/Cargo.toml | 1 + sqlx-macros/Cargo.toml | 1 + sqlx-postgres/Cargo.toml | 2 + sqlx-postgres/src/type_checking.rs | 6 + sqlx-postgres/src/type_info.rs | 2 +- sqlx-postgres/src/types/ipnet/ipaddr.rs | 62 +++++++++ sqlx-postgres/src/types/ipnet/ipnet.rs | 123 ++++++++++++++++++ sqlx-postgres/src/types/ipnet/mod.rs | 5 + .../src/types/{ => ipnetwork}/ipaddr.rs | 0 .../src/types/{ => ipnetwork}/ipnetwork.rs | 0 sqlx-postgres/src/types/ipnetwork/mod.rs | 7 + sqlx-postgres/src/types/mod.rs | 25 +++- tests/postgres/types.rs | 37 ++++++ tests/ui-tests.rs | 4 +- .../postgres/gated/{ipnetwork.rs => ipnet.rs} | 0 .../gated/{ipnetwork.stderr => ipnet.stderr} | 16 +-- 21 files changed, 294 insertions(+), 19 deletions(-) create mode 100644 sqlx-postgres/src/types/ipnet/ipaddr.rs create mode 100644 sqlx-postgres/src/types/ipnet/ipnet.rs create mode 100644 sqlx-postgres/src/types/ipnet/mod.rs rename sqlx-postgres/src/types/{ => ipnetwork}/ipaddr.rs (100%) rename sqlx-postgres/src/types/{ => ipnetwork}/ipnetwork.rs (100%) create mode 100644 sqlx-postgres/src/types/ipnetwork/mod.rs rename tests/ui/postgres/gated/{ipnetwork.rs => ipnet.rs} (100%) rename tests/ui/postgres/gated/{ipnetwork.stderr => ipnet.stderr} (67%) diff --git a/Cargo.lock b/Cargo.lock index c112899415..a0eabbeddc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1987,6 +1987,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "ipnet" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" + [[package]] name = "ipnetwork" version = "0.20.0" @@ -3580,6 +3586,7 @@ dependencies = [ "hashbrown 0.15.2", "hashlink", "indexmap 2.7.0", + "ipnet", "ipnetwork", "log", "mac_address", @@ -3836,6 +3843,7 @@ dependencies = [ "hkdf", "hmac", "home", + "ipnet", "ipnetwork", "itoa", "log", diff --git a/Cargo.toml b/Cargo.toml index f93ed3dded..488f7ade02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,7 @@ _unstable-all-types = [ "json", "time", "chrono", + "ipnet", "ipnetwork", "mac_address", "uuid", @@ -116,6 +117,7 @@ json = ["sqlx-macros?/json", "sqlx-mysql?/json", "sqlx-postgres?/json", "sqlx-sq bigdecimal = ["sqlx-core/bigdecimal", "sqlx-macros?/bigdecimal", "sqlx-mysql?/bigdecimal", "sqlx-postgres?/bigdecimal"] bit-vec = ["sqlx-core/bit-vec", "sqlx-macros?/bit-vec", "sqlx-postgres?/bit-vec"] chrono = ["sqlx-core/chrono", "sqlx-macros?/chrono", "sqlx-mysql?/chrono", "sqlx-postgres?/chrono", "sqlx-sqlite?/chrono"] +ipnet = ["sqlx-core/ipnet", "sqlx-macros?/ipnet", "sqlx-postgres?/ipnet"] ipnetwork = ["sqlx-core/ipnetwork", "sqlx-macros?/ipnetwork", "sqlx-postgres?/ipnetwork"] mac_address = ["sqlx-core/mac_address", "sqlx-macros?/mac_address", "sqlx-postgres?/mac_address"] rust_decimal = ["sqlx-core/rust_decimal", "sqlx-macros?/rust_decimal", "sqlx-mysql?/rust_decimal", "sqlx-postgres?/rust_decimal"] @@ -142,7 +144,7 @@ sqlx = { version = "=0.8.3", path = ".", default-features = false } bigdecimal = "0.4.0" bit-vec = "0.6.3" chrono = { version = "0.4.34", default-features = false, features = ["std", "clock"] } -ipnetwork = "0.20.0" +ipnet = "2.3.0" mac_address = "1.1.5" rust_decimal = { version = "1.26.1", default-features = false, features = ["std"] } time = { version = "0.3.36", features = ["formatting", "parsing", "macros"] } diff --git a/README.md b/README.md index 15d68bbb42..fc8d3b7427 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,8 @@ be removed in the future. - `rust_decimal`: Add support for `NUMERIC` using the `rust_decimal` crate. +- `ipnet`: Add support for `INET` and `CIDR` (in postgres) using the `ipnet` crate. + - `ipnetwork`: Add support for `INET` and `CIDR` (in postgres) using the `ipnetwork` crate. - `json`: Add support for `JSON` and `JSONB` (in postgres) using the `serde_json` crate. diff --git a/sqlx-core/Cargo.toml b/sqlx-core/Cargo.toml index f767507bb4..b8b7d0eda3 100644 --- a/sqlx-core/Cargo.toml +++ b/sqlx-core/Cargo.toml @@ -49,6 +49,7 @@ bit-vec = { workspace = true, optional = true } bigdecimal = { workspace = true, optional = true } rust_decimal = { workspace = true, optional = true } time = { workspace = true, optional = true } +ipnet = { workspace = true, optional = true } ipnetwork = { workspace = true, optional = true } mac_address = { workspace = true, optional = true } uuid = { workspace = true, optional = true } diff --git a/sqlx-core/src/types/mod.rs b/sqlx-core/src/types/mod.rs index 25837b1e77..d36bec49ed 100644 --- a/sqlx-core/src/types/mod.rs +++ b/sqlx-core/src/types/mod.rs @@ -67,6 +67,13 @@ pub use bigdecimal::BigDecimal; #[doc(no_inline)] pub use rust_decimal::Decimal; +#[cfg(feature = "ipnet")] +#[cfg_attr(docsrs, doc(cfg(feature = "ipnet")))] +pub mod ipnet { + #[doc(no_inline)] + pub use ipnet::{IpNet, Ipv4Net, Ipv6Net}; +} + #[cfg(feature = "ipnetwork")] #[cfg_attr(docsrs, doc(cfg(feature = "ipnetwork")))] pub mod ipnetwork { diff --git a/sqlx-macros-core/Cargo.toml b/sqlx-macros-core/Cargo.toml index 46786b7d8d..85efa80912 100644 --- a/sqlx-macros-core/Cargo.toml +++ b/sqlx-macros-core/Cargo.toml @@ -38,6 +38,7 @@ json = ["sqlx-core/json", "sqlx-mysql?/json", "sqlx-postgres?/json", "sqlx-sqlit bigdecimal = ["sqlx-core/bigdecimal", "sqlx-mysql?/bigdecimal", "sqlx-postgres?/bigdecimal"] bit-vec = ["sqlx-core/bit-vec", "sqlx-postgres?/bit-vec"] chrono = ["sqlx-core/chrono", "sqlx-mysql?/chrono", "sqlx-postgres?/chrono", "sqlx-sqlite?/chrono"] +ipnet = ["sqlx-core/ipnet", "sqlx-postgres?/ipnet"] ipnetwork = ["sqlx-core/ipnetwork", "sqlx-postgres?/ipnetwork"] mac_address = ["sqlx-core/mac_address", "sqlx-postgres?/mac_address"] rust_decimal = ["sqlx-core/rust_decimal", "sqlx-mysql?/rust_decimal", "sqlx-postgres?/rust_decimal"] diff --git a/sqlx-macros/Cargo.toml b/sqlx-macros/Cargo.toml index 5617d3f251..b513c3e808 100644 --- a/sqlx-macros/Cargo.toml +++ b/sqlx-macros/Cargo.toml @@ -37,6 +37,7 @@ sqlite-unbundled = ["sqlx-macros-core/sqlite-unbundled"] bigdecimal = ["sqlx-macros-core/bigdecimal"] bit-vec = ["sqlx-macros-core/bit-vec"] chrono = ["sqlx-macros-core/chrono"] +ipnet = ["sqlx-macros-core/ipnet"] ipnetwork = ["sqlx-macros-core/ipnetwork"] mac_address = ["sqlx-macros-core/mac_address"] rust_decimal = ["sqlx-macros-core/rust_decimal"] diff --git a/sqlx-postgres/Cargo.toml b/sqlx-postgres/Cargo.toml index 174a73b3fa..818aadbab7 100644 --- a/sqlx-postgres/Cargo.toml +++ b/sqlx-postgres/Cargo.toml @@ -19,6 +19,7 @@ offline = ["sqlx-core/offline"] bigdecimal = ["dep:bigdecimal", "dep:num-bigint", "sqlx-core/bigdecimal"] bit-vec = ["dep:bit-vec", "sqlx-core/bit-vec"] chrono = ["dep:chrono", "sqlx-core/chrono"] +ipnet = ["dep:ipnet", "sqlx-core/ipnet"] ipnetwork = ["dep:ipnetwork", "sqlx-core/ipnetwork"] mac_address = ["dep:mac_address", "sqlx-core/mac_address"] rust_decimal = ["dep:rust_decimal", "rust_decimal/maths", "sqlx-core/rust_decimal"] @@ -43,6 +44,7 @@ sha2 = { version = "0.10.0", default-features = false } bigdecimal = { workspace = true, optional = true } bit-vec = { workspace = true, optional = true } chrono = { workspace = true, optional = true } +ipnet = { workspace = true, optional = true } ipnetwork = { workspace = true, optional = true } mac_address = { workspace = true, optional = true } rust_decimal = { workspace = true, optional = true } diff --git a/sqlx-postgres/src/type_checking.rs b/sqlx-postgres/src/type_checking.rs index 314fda0b17..cf7d29f6ce 100644 --- a/sqlx-postgres/src/type_checking.rs +++ b/sqlx-postgres/src/type_checking.rs @@ -77,6 +77,9 @@ impl_type_checking!( #[cfg(feature = "rust_decimal")] sqlx::types::Decimal, + #[cfg(all(feature = "ipnet", not(feature = "ipnetwork")))] + sqlx::types::ipnet::IpNet, + #[cfg(feature = "ipnetwork")] sqlx::types::ipnetwork::IpNetwork, @@ -138,6 +141,9 @@ impl_type_checking!( #[cfg(feature = "rust_decimal")] Vec | &[sqlx::types::Decimal], + #[cfg(all(feature = "ipnet", not(feature = "ipnetwork")))] + Vec | &[sqlx::types::ipnet::IpNet], + #[cfg(feature = "ipnetwork")] Vec | &[sqlx::types::ipnetwork::IpNetwork], diff --git a/sqlx-postgres/src/type_info.rs b/sqlx-postgres/src/type_info.rs index 28c56758e9..8481c1d236 100644 --- a/sqlx-postgres/src/type_info.rs +++ b/sqlx-postgres/src/type_info.rs @@ -256,7 +256,7 @@ impl PgTypeInfo { ] .contains(self) { - Some("ipnetwork") + Some("ipnet") } else if [PgTypeInfo::MACADDR].contains(self) { Some("mac_address") } else if [PgTypeInfo::NUMERIC, PgTypeInfo::NUMERIC_ARRAY].contains(self) { diff --git a/sqlx-postgres/src/types/ipnet/ipaddr.rs b/sqlx-postgres/src/types/ipnet/ipaddr.rs new file mode 100644 index 0000000000..efeea4e1cc --- /dev/null +++ b/sqlx-postgres/src/types/ipnet/ipaddr.rs @@ -0,0 +1,62 @@ +use std::net::IpAddr; + +use ipnet::IpNet; + +use crate::decode::Decode; +use crate::encode::{Encode, IsNull}; +use crate::error::BoxDynError; +use crate::types::Type; +use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueRef, Postgres}; + +impl Type for IpAddr +where + IpNet: Type, +{ + fn type_info() -> PgTypeInfo { + IpNet::type_info() + } + + fn compatible(ty: &PgTypeInfo) -> bool { + IpNet::compatible(ty) + } +} + +impl PgHasArrayType for IpAddr { + fn array_type_info() -> PgTypeInfo { + ::array_type_info() + } + + fn array_compatible(ty: &PgTypeInfo) -> bool { + ::array_compatible(ty) + } +} + +impl<'db> Encode<'db, Postgres> for IpAddr +where + IpNet: Encode<'db, Postgres>, +{ + fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> Result { + IpNet::from(*self).encode_by_ref(buf) + } + + fn size_hint(&self) -> usize { + IpNet::from(*self).size_hint() + } +} + +impl<'db> Decode<'db, Postgres> for IpAddr +where + IpNet: Decode<'db, Postgres>, +{ + fn decode(value: PgValueRef<'db>) -> Result { + let ipnet = IpNet::decode(value)?; + + if matches!(ipnet, IpNet::V4(_)) && ipnet.prefix_len() != 32 + || matches!(ipnet, IpNet::V6(_)) && ipnet.prefix_len() != 128 + { + Err("lossy decode from inet/cidr")? + } + + Ok(ipnet.addr()) + } +} diff --git a/sqlx-postgres/src/types/ipnet/ipnet.rs b/sqlx-postgres/src/types/ipnet/ipnet.rs new file mode 100644 index 0000000000..fc8bd4e210 --- /dev/null +++ b/sqlx-postgres/src/types/ipnet/ipnet.rs @@ -0,0 +1,123 @@ +use std::net::{Ipv4Addr, Ipv6Addr}; + +#[cfg(feature = "ipnet")] +use ipnet::{IpNet, Ipv4Net, Ipv6Net}; + +use crate::decode::Decode; +use crate::encode::{Encode, IsNull}; +use crate::error::BoxDynError; +use crate::types::Type; +use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueFormat, PgValueRef, Postgres}; + +// https://github.com/postgres/postgres/blob/574925bfd0a8175f6e161936ea11d9695677ba09/src/include/utils/inet.h#L39 + +// Technically this is a magic number here but it doesn't make sense to drag in the whole of `libc` +// just for one constant. +const PGSQL_AF_INET: u8 = 2; // AF_INET +const PGSQL_AF_INET6: u8 = PGSQL_AF_INET + 1; + +impl Type for IpNet { + fn type_info() -> PgTypeInfo { + PgTypeInfo::INET + } + + fn compatible(ty: &PgTypeInfo) -> bool { + *ty == PgTypeInfo::CIDR || *ty == PgTypeInfo::INET + } +} + +impl PgHasArrayType for IpNet { + fn array_type_info() -> PgTypeInfo { + PgTypeInfo::INET_ARRAY + } + + fn array_compatible(ty: &PgTypeInfo) -> bool { + *ty == PgTypeInfo::CIDR_ARRAY || *ty == PgTypeInfo::INET_ARRAY + } +} + +impl Encode<'_, Postgres> for IpNet { + fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> Result { + // https://github.com/postgres/postgres/blob/574925bfd0a8175f6e161936ea11d9695677ba09/src/backend/utils/adt/network.c#L293 + // https://github.com/postgres/postgres/blob/574925bfd0a8175f6e161936ea11d9695677ba09/src/backend/utils/adt/network.c#L271 + + match self { + IpNet::V4(net) => { + buf.push(PGSQL_AF_INET); // ip_family + buf.push(net.prefix_len()); // ip_bits + buf.push(0); // is_cidr + buf.push(4); // nb (number of bytes) + buf.extend_from_slice(&net.addr().octets()) // address + } + + IpNet::V6(net) => { + buf.push(PGSQL_AF_INET6); // ip_family + buf.push(net.prefix_len()); // ip_bits + buf.push(0); // is_cidr + buf.push(16); // nb (number of bytes) + buf.extend_from_slice(&net.addr().octets()); // address + } + } + + Ok(IsNull::No) + } + + fn size_hint(&self) -> usize { + match self { + IpNet::V4(_) => 8, + IpNet::V6(_) => 20, + } + } +} + +impl Decode<'_, Postgres> for IpNet { + fn decode(value: PgValueRef<'_>) -> Result { + let bytes = match value.format() { + PgValueFormat::Binary => value.as_bytes()?, + PgValueFormat::Text => { + return Ok(value.as_str()?.parse()?); + } + }; + + if bytes.len() >= 8 { + let family = bytes[0]; + let prefix = bytes[1]; + let _is_cidr = bytes[2] != 0; + let len = bytes[3]; + + match family { + PGSQL_AF_INET => { + if bytes.len() == 8 && len == 4 { + let inet = Ipv4Net::new( + Ipv4Addr::new(bytes[4], bytes[5], bytes[6], bytes[7]), + prefix, + )?; + + return Ok(IpNet::V4(inet)); + } + } + + PGSQL_AF_INET6 => { + if bytes.len() == 20 && len == 16 { + let inet = Ipv6Net::new( + Ipv6Addr::from([ + bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], + bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15], + bytes[16], bytes[17], bytes[18], bytes[19], + ]), + prefix, + )?; + + return Ok(IpNet::V6(inet)); + } + } + + _ => { + return Err(format!("unknown ip family {family}").into()); + } + } + } + + Err("invalid data received when expecting an INET".into()) + } +} diff --git a/sqlx-postgres/src/types/ipnet/mod.rs b/sqlx-postgres/src/types/ipnet/mod.rs new file mode 100644 index 0000000000..a0f653bb30 --- /dev/null +++ b/sqlx-postgres/src/types/ipnet/mod.rs @@ -0,0 +1,5 @@ +mod ipaddr; + +// Parent module is named after the `ipnet` crate, this is named after the `IpNet` type. +#[allow(clippy::module_inception)] +mod ipnet; diff --git a/sqlx-postgres/src/types/ipaddr.rs b/sqlx-postgres/src/types/ipnetwork/ipaddr.rs similarity index 100% rename from sqlx-postgres/src/types/ipaddr.rs rename to sqlx-postgres/src/types/ipnetwork/ipaddr.rs diff --git a/sqlx-postgres/src/types/ipnetwork.rs b/sqlx-postgres/src/types/ipnetwork/ipnetwork.rs similarity index 100% rename from sqlx-postgres/src/types/ipnetwork.rs rename to sqlx-postgres/src/types/ipnetwork/ipnetwork.rs diff --git a/sqlx-postgres/src/types/ipnetwork/mod.rs b/sqlx-postgres/src/types/ipnetwork/mod.rs new file mode 100644 index 0000000000..054e6b795b --- /dev/null +++ b/sqlx-postgres/src/types/ipnetwork/mod.rs @@ -0,0 +1,7 @@ +// Prefer `ipnet` over `ipnetwork`, as it is more featureful and more widely used. +#[cfg(not(feature = "ipnet"))] +mod ipaddr; + +// Parent module is named after the `ipnetwork` crate, this is named after the `IpNetwork` type. +#[allow(clippy::module_inception)] +mod ipnetwork; diff --git a/sqlx-postgres/src/types/mod.rs b/sqlx-postgres/src/types/mod.rs index b5b3266cbc..80e55f1bc3 100644 --- a/sqlx-postgres/src/types/mod.rs +++ b/sqlx-postgres/src/types/mod.rs @@ -81,20 +81,31 @@ //! |---------------------------------------|------------------------------------------------------| //! | `uuid::Uuid` | UUID | //! -//! ### [`ipnetwork`](https://crates.io/crates/ipnetwork) +//! ### [`ipnet`](https://crates.io/crates/ipnet) //! -//! Requires the `ipnetwork` Cargo feature flag. +//! Requires the `ipnet` Cargo feature flag (takes precedence over `ipnetwork` if both are used). //! //! | Rust type | Postgres type(s) | //! |---------------------------------------|------------------------------------------------------| -//! | `ipnetwork::IpNetwork` | INET, CIDR | +//! | `ipnet::IpNet` | INET, CIDR | //! | `std::net::IpAddr` | INET, CIDR | //! //! Note that because `IpAddr` does not support network prefixes, it is an error to attempt to decode //! an `IpAddr` from a `INET` or `CIDR` value with a network prefix smaller than the address' full width: //! `/32` for IPv4 addresses and `/128` for IPv6 addresses. //! -//! `IpNetwork` does not have this limitation. +//! `IpNet` does not have this limitation. +//! +//! ### [`ipnetwork`](https://crates.io/crates/ipnetwork) +//! +//! Requires the `ipnetwork` Cargo feature flag. +//! +//! | Rust type | Postgres type(s) | +//! |---------------------------------------|------------------------------------------------------| +//! | `ipnetwork::IpNetwork` | INET, CIDR | +//! | `std::net::IpAddr` | INET, CIDR | +//! +//! The same `IpAddr` limitation for smaller network prefixes applies as with `ipnet`. //! //! ### [`mac_address`](https://crates.io/crates/mac_address) //! @@ -244,11 +255,11 @@ mod time; #[cfg(feature = "uuid")] mod uuid; -#[cfg(feature = "ipnetwork")] -mod ipnetwork; +#[cfg(feature = "ipnet")] +mod ipnet; #[cfg(feature = "ipnetwork")] -mod ipaddr; +mod ipnetwork; #[cfg(feature = "mac_address")] mod mac_address; diff --git a/tests/postgres/types.rs b/tests/postgres/types.rs index c1cf87983c..34591cb247 100644 --- a/tests/postgres/types.rs +++ b/tests/postgres/types.rs @@ -171,6 +171,34 @@ test_type!(uuid_vec>(Postgres, ] )); +#[cfg(feature = "ipnet")] +test_type!(ipnet(Postgres, + "'127.0.0.1'::inet" + == "127.0.0.1" + .parse::() + .unwrap(), + "'8.8.8.8/24'::inet" + == "8.8.8.8/24" + .parse::() + .unwrap(), + "'::ffff:1.2.3.0'::inet" + == "::ffff:1.2.3.0" + .parse::() + .unwrap(), + "'2001:4f8:3:ba::/64'::inet" + == "2001:4f8:3:ba::/64" + .parse::() + .unwrap(), + "'192.168'::cidr" + == "192.168.0.0/24" + .parse::() + .unwrap(), + "'::ffff:1.2.3.0/120'::cidr" + == "::ffff:1.2.3.0/120" + .parse::() + .unwrap(), +)); + #[cfg(feature = "ipnetwork")] test_type!(ipnetwork(Postgres, "'127.0.0.1'::inet" @@ -232,6 +260,15 @@ test_type!(bitvec( }, )); +#[cfg(feature = "ipnet")] +test_type!(ipnet_vec>(Postgres, + "'{127.0.0.1,8.8.8.8/24}'::inet[]" + == vec![ + "127.0.0.1".parse::().unwrap(), + "8.8.8.8/24".parse::().unwrap() + ] +)); + #[cfg(feature = "ipnetwork")] test_type!(ipnetwork_vec>(Postgres, "'{127.0.0.1,8.8.8.8/24}'::inet[]" diff --git a/tests/ui-tests.rs b/tests/ui-tests.rs index f74694b870..7e7ffe9708 100644 --- a/tests/ui-tests.rs +++ b/tests/ui-tests.rs @@ -17,8 +17,8 @@ fn ui_tests() { t.compile_fail("tests/ui/postgres/gated/uuid.rs"); } - if cfg!(not(feature = "ipnetwork")) { - t.compile_fail("tests/ui/postgres/gated/ipnetwork.rs"); + if cfg!(not(feature = "ipnet")) && cfg!(not(feature = "ipnetwork")) { + t.compile_fail("tests/ui/postgres/gated/ipnet.rs"); } } diff --git a/tests/ui/postgres/gated/ipnetwork.rs b/tests/ui/postgres/gated/ipnet.rs similarity index 100% rename from tests/ui/postgres/gated/ipnetwork.rs rename to tests/ui/postgres/gated/ipnet.rs diff --git a/tests/ui/postgres/gated/ipnetwork.stderr b/tests/ui/postgres/gated/ipnet.stderr similarity index 67% rename from tests/ui/postgres/gated/ipnetwork.stderr rename to tests/ui/postgres/gated/ipnet.stderr index 2044d04e8c..d2a9dfb774 100644 --- a/tests/ui/postgres/gated/ipnetwork.stderr +++ b/tests/ui/postgres/gated/ipnet.stderr @@ -1,29 +1,29 @@ -error: optional sqlx feature `ipnetwork` required for type INET of column #1 ("inet") - --> $DIR/ipnetwork.rs:2:13 +error: optional sqlx feature `ipnet` required for type INET of column #1 ("inet") + --> $DIR/ipnet.rs:2:13 | 2 | let _ = sqlx::query!("select '127.0.0.1'::inet"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: optional sqlx feature `ipnetwork` required for type CIDR of column #1 ("cidr") - --> $DIR/ipnetwork.rs:4:13 +error: optional sqlx feature `ipnet` required for type CIDR of column #1 ("cidr") + --> $DIR/ipnet.rs:4:13 | 4 | let _ = sqlx::query!("select '2001:4f8:3:ba::/64'::cidr"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: optional sqlx feature `ipnetwork` required for type INET of param #1 - --> $DIR/ipnetwork.rs:6:13 +error: optional sqlx feature `ipnet` required for type INET of param #1 + --> $DIR/ipnet.rs:6:13 | 6 | let _ = sqlx::query!("select $1::inet", ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: optional sqlx feature `ipnetwork` required for type CIDR of param #1 - --> $DIR/ipnetwork.rs:8:13 +error: optional sqlx feature `ipnet` required for type CIDR of param #1 + --> $DIR/ipnet.rs:8:13 | 8 | let _ = sqlx::query!("select $1::cidr", ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^