Skip to content

Commit ab98e23

Browse files
committed
fix: restore original type-checking order
1 parent 52bb9d0 commit ab98e23

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

sqlx-core/src/type_checking.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,22 @@ macro_rules! impl_type_checking {
189189
) -> Result<&'static str, $crate::type_checking::Error> {
190190
use $crate::config::macros::{DateTimeCrate, NumericCrate};
191191
use $crate::type_checking::Error;
192+
193+
// Check non-special types
194+
// ---------------------
195+
$(
196+
$(#[$meta])?
197+
if <$ty as sqlx_core::types::Type<$database>>::type_info() == *info {
198+
return Ok($crate::select_input_type!($ty $(, $input)?));
199+
}
200+
)*
201+
202+
$(
203+
$(#[$meta])?
204+
if <$ty as sqlx_core::types::Type<$database>>::compatible(info) {
205+
return Ok($crate::select_input_type!($ty $(, $input)?));
206+
}
207+
)*
192208

193209
// Check `macros.preferred-crates.date-time`
194210
//
@@ -304,32 +320,32 @@ macro_rules! impl_type_checking {
304320
return Err(Error::NumericCrateFeatureNotEnabled);
305321
}
306322

307-
// Check all other types
323+
Err(Error::NoMappingFound)
324+
}
325+
326+
fn return_type_for_id(
327+
info: &Self::TypeInfo,
328+
preferred_crates: &$crate::config::macros::PreferredCrates,
329+
) -> Result<&'static str, $crate::type_checking::Error> {
330+
use $crate::config::macros::{DateTimeCrate, NumericCrate};
331+
use $crate::type_checking::Error;
332+
333+
// Check non-special types
308334
// ---------------------
309335
$(
310336
$(#[$meta])?
311337
if <$ty as sqlx_core::types::Type<$database>>::type_info() == *info {
312-
return Ok($crate::select_input_type!($ty $(, $input)?));
338+
return Ok(stringify!($ty));
313339
}
314340
)*
315341

316342
$(
317343
$(#[$meta])?
318344
if <$ty as sqlx_core::types::Type<$database>>::compatible(info) {
319-
return Ok($crate::select_input_type!($ty $(, $input)?));
345+
return Ok(stringify!($ty));
320346
}
321347
)*
322-
323-
Err(Error::NoMappingFound)
324-
}
325-
326-
fn return_type_for_id(
327-
info: &Self::TypeInfo,
328-
preferred_crates: &$crate::config::macros::PreferredCrates,
329-
) -> Result<&'static str, $crate::type_checking::Error> {
330-
use $crate::config::macros::{DateTimeCrate, NumericCrate};
331-
use $crate::type_checking::Error;
332-
348+
333349
// Check `macros.preferred-crates.date-time`
334350
//
335351
// Due to legacy reasons, `time` takes precedent over `chrono` if both are enabled.
@@ -444,22 +460,6 @@ macro_rules! impl_type_checking {
444460
return Err(Error::NumericCrateFeatureNotEnabled);
445461
}
446462

447-
// Check all other types
448-
// ---------------------
449-
$(
450-
$(#[$meta])?
451-
if <$ty as sqlx_core::types::Type<$database>>::type_info() == *info {
452-
return Ok(stringify!($ty));
453-
}
454-
)*
455-
456-
$(
457-
$(#[$meta])?
458-
if <$ty as sqlx_core::types::Type<$database>>::compatible(info) {
459-
return Ok(stringify!($ty));
460-
}
461-
)*
462-
463463
Err(Error::NoMappingFound)
464464
}
465465

0 commit comments

Comments
 (0)