1pub(super) mod date_and_time;
4mod enum_;
5#[cfg(feature = "serde_json")]
6mod json;
7mod numeric;
8mod primitives;
9
10use self::primitives::{decimal_to_integer, f32_to_i64, f64_to_i64, narrow};
11use crate::deserialize::{self, FromSql};
12use crate::mysql_like::MysqlLikeBackend;
13use crate::mysql_like::NumericRepresentation;
14use crate::mysql_like::{MysqlType, MysqlValue};
15use crate::query_builder::QueryId;
16use crate::serialize::{self, IsNull, Output, ToSql};
17use crate::sql_types::ops::*;
18use crate::sql_types::*;
19use crate::sql_types::{self};
20use byteorder::{NativeEndian, WriteBytesExt};
21
22impl<DB: MysqlLikeBackend> ToSql<TinyInt, DB> for i8 {
23 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
24 out.write_i8(*self).map(|_| IsNull::No).map_err(Into::into)
25 }
26}
27
28impl<DB: MysqlLikeBackend> FromSql<TinyInt, DB> for i8 {
29 fn from_sql(value: MysqlValue<'_>) -> deserialize::Result<Self> {
30 match value.numeric_value()? {
31 NumericRepresentation::Tiny(x) => Ok(x),
32 NumericRepresentation::UnsignedTiny(x) => narrow(x),
33 NumericRepresentation::Small(x) => narrow(x),
34 NumericRepresentation::UnsignedSmall(x) => narrow(x),
35 NumericRepresentation::Medium(x) => narrow(x),
36 NumericRepresentation::UnsignedMedium(x) => narrow(x),
37 NumericRepresentation::Big(x) => narrow(x),
38 NumericRepresentation::UnsignedBig(x) => narrow(x),
39 NumericRepresentation::Float(x) => narrow(f32_to_i64(x)?),
40 NumericRepresentation::Double(x) => narrow(f64_to_i64(x)?),
41 NumericRepresentation::Decimal(bytes) => decimal_to_integer(bytes),
42 }
43 }
44}
45
46#[derive(#[automatically_derived]impl<ST: ::core::fmt::Debug + 'static>
::core::fmt::Debug for Unsigned<ST> {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "Unsigned",
&&self.0)
}
}Debug, #[automatically_derived]impl<ST: ::core::clone::Clone + 'static>
::core::clone::Clone for Unsigned<ST> {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { Unsigned(::core::clone::Clone::clone(&self.0)) }
}Clone, #[automatically_derived]impl<ST: ::core::marker::Copy + 'static>
::core::marker::Copy for Unsigned<ST> {
}Copy, #[automatically_derived]impl<ST: ::core::default::Default + 'static>
::core::default::Default for Unsigned<ST> {
#[inline]
fn default() -> Self { Unsigned(::core::default::Default::default()) }
}Default, const _: () =
{
use diesel;
impl<ST: 'static> diesel::sql_types::SqlType for Unsigned<ST> {
type IsNull = diesel::sql_types::is_nullable::NotNull;
const IS_ARRAY: bool = false;
}
impl<ST: 'static> diesel::sql_types::SingleValue for Unsigned<ST> {}
};SqlType, const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<ST: 'static + diesel::query_builder::QueryId>
diesel::query_builder::QueryId for Unsigned<ST> {
type QueryId =
Unsigned<<ST as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<ST as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<ST as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};QueryId)]
48pub struct Unsigned<ST: 'static>(ST);
49
50impl<T> Add for Unsigned<T>
51where
52 T: Add,
53{
54 type Rhs = Unsigned<T::Rhs>;
55 type Output = Unsigned<T::Output>;
56}
57
58impl<T> Sub for Unsigned<T>
59where
60 T: Sub,
61{
62 type Rhs = Unsigned<T::Rhs>;
63 type Output = Unsigned<T::Output>;
64}
65
66impl<T> Mul for Unsigned<T>
67where
68 T: Mul,
69{
70 type Rhs = Unsigned<T::Rhs>;
71 type Output = Unsigned<T::Output>;
72}
73
74impl<T> Div for Unsigned<T>
75where
76 T: Div,
77{
78 type Rhs = Unsigned<T::Rhs>;
79 type Output = Unsigned<T::Output>;
80}
81
82impl<DB: MysqlLikeBackend> ToSql<Unsigned<TinyInt>, DB> for u8 {
83 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
84 out.write_u8(*self)?;
85 Ok(IsNull::No)
86 }
87}
88
89impl<DB: MysqlLikeBackend> FromSql<Unsigned<TinyInt>, DB> for u8 {
90 fn from_sql(value: MysqlValue<'_>) -> deserialize::Result<Self> {
91 match value.numeric_value()? {
92 NumericRepresentation::Tiny(x) => narrow(x),
93 NumericRepresentation::UnsignedTiny(x) => Ok(x),
94 NumericRepresentation::Small(x) => narrow(x),
95 NumericRepresentation::UnsignedSmall(x) => narrow(x),
96 NumericRepresentation::Medium(x) => narrow(x),
97 NumericRepresentation::UnsignedMedium(x) => narrow(x),
98 NumericRepresentation::Big(x) => narrow(x),
99 NumericRepresentation::UnsignedBig(x) => narrow(x),
100 NumericRepresentation::Float(x) => narrow(f32_to_i64(x)?),
101 NumericRepresentation::Double(x) => narrow(f64_to_i64(x)?),
102 NumericRepresentation::Decimal(bytes) => decimal_to_integer(bytes),
103 }
104 }
105}
106
107impl<DB: MysqlLikeBackend> ToSql<Unsigned<SmallInt>, DB> for u16 {
108 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
109 out.write_u16::<NativeEndian>(*self)?;
110 Ok(IsNull::No)
111 }
112}
113
114impl<DB: MysqlLikeBackend> FromSql<Unsigned<SmallInt>, DB> for u16 {
115 fn from_sql(value: MysqlValue<'_>) -> deserialize::Result<Self> {
116 match value.numeric_value()? {
117 NumericRepresentation::Tiny(x) => narrow(x),
118 NumericRepresentation::UnsignedTiny(x) => Ok(x.into()),
119 NumericRepresentation::Small(x) => narrow(x),
120 NumericRepresentation::UnsignedSmall(x) => Ok(x),
121 NumericRepresentation::Medium(x) => narrow(x),
122 NumericRepresentation::UnsignedMedium(x) => narrow(x),
123 NumericRepresentation::Big(x) => narrow(x),
124 NumericRepresentation::UnsignedBig(x) => narrow(x),
125 NumericRepresentation::Float(x) => narrow(f32_to_i64(x)?),
126 NumericRepresentation::Double(x) => narrow(f64_to_i64(x)?),
127 NumericRepresentation::Decimal(bytes) => decimal_to_integer(bytes),
128 }
129 }
130}
131
132impl<DB: MysqlLikeBackend> ToSql<Unsigned<Integer>, DB> for u32 {
133 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
134 out.write_u32::<NativeEndian>(*self)?;
135 Ok(IsNull::No)
136 }
137}
138
139impl<DB: MysqlLikeBackend> FromSql<Unsigned<Integer>, DB> for u32 {
140 fn from_sql(value: MysqlValue<'_>) -> deserialize::Result<Self> {
141 match value.numeric_value()? {
142 NumericRepresentation::Tiny(x) => narrow(x),
143 NumericRepresentation::UnsignedTiny(x) => Ok(x.into()),
144 NumericRepresentation::Small(x) => narrow(x),
145 NumericRepresentation::UnsignedSmall(x) => Ok(x.into()),
146 NumericRepresentation::Medium(x) => narrow(x),
147 NumericRepresentation::UnsignedMedium(x) => Ok(x),
148 NumericRepresentation::Big(x) => narrow(x),
149 NumericRepresentation::UnsignedBig(x) => narrow(x),
150 NumericRepresentation::Float(x) => narrow(f32_to_i64(x)?),
151 NumericRepresentation::Double(x) => narrow(f64_to_i64(x)?),
152 NumericRepresentation::Decimal(bytes) => decimal_to_integer(bytes),
153 }
154 }
155}
156
157impl<DB: MysqlLikeBackend> ToSql<Unsigned<BigInt>, DB> for u64 {
158 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
159 out.write_u64::<NativeEndian>(*self)?;
160 Ok(IsNull::No)
161 }
162}
163
164impl<DB: MysqlLikeBackend> FromSql<Unsigned<BigInt>, DB> for u64 {
165 fn from_sql(value: MysqlValue<'_>) -> deserialize::Result<Self> {
166 match value.numeric_value()? {
168 NumericRepresentation::Tiny(x) => narrow(x),
169 NumericRepresentation::UnsignedTiny(x) => Ok(x.into()),
170 NumericRepresentation::Small(x) => narrow(x),
171 NumericRepresentation::UnsignedSmall(x) => Ok(x.into()),
172 NumericRepresentation::Medium(x) => narrow(x),
173 NumericRepresentation::UnsignedMedium(x) => Ok(x.into()),
174 NumericRepresentation::Big(x) => narrow(x),
175 NumericRepresentation::UnsignedBig(x) => Ok(x),
176 NumericRepresentation::Float(x) => narrow(f32_to_i64(x)?),
177 NumericRepresentation::Double(x) => narrow(f64_to_i64(x)?),
178 NumericRepresentation::Decimal(bytes) => decimal_to_integer(bytes),
179 }
180 }
181}
182
183impl<DB: MysqlLikeBackend> ToSql<Bool, DB> for bool {
184 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
185 let int_value = i32::from(*self);
186 <i32 as ToSql<Integer, DB>>::to_sql(&int_value, &mut out.reborrow())
187 }
188}
189
190impl<DB: MysqlLikeBackend> FromSql<Bool, DB> for bool {
191 fn from_sql(bytes: MysqlValue<'_>) -> deserialize::Result<Self> {
192 Ok(bytes.as_bytes().iter().any(|x| *x != 0))
193 }
194}
195
196impl<DB: MysqlLikeBackend> ToSql<sql_types::SmallInt, DB> for i16 {
197 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
198 out.write_i16::<NativeEndian>(*self)
199 .map(|_| IsNull::No)
200 .map_err(|e| Box::new(e) as Box<_>)
201 }
202}
203
204impl<DB: MysqlLikeBackend> ToSql<sql_types::Integer, DB> for i32 {
205 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
206 out.write_i32::<NativeEndian>(*self)
207 .map(|_| IsNull::No)
208 .map_err(|e| Box::new(e) as Box<_>)
209 }
210}
211
212impl<DB: MysqlLikeBackend> ToSql<sql_types::BigInt, DB> for i64 {
213 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
214 out.write_i64::<NativeEndian>(*self)
215 .map(|_| IsNull::No)
216 .map_err(|e| Box::new(e) as Box<_>)
217 }
218}
219
220impl<DB: MysqlLikeBackend> ToSql<sql_types::Double, DB> for f64 {
221 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
222 out.write_f64::<NativeEndian>(*self)
223 .map(|_| IsNull::No)
224 .map_err(|e| Box::new(e) as Box<_>)
225 }
226}
227
228impl<DB: MysqlLikeBackend> ToSql<sql_types::Float, DB> for f32 {
229 fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
230 out.write_f32::<NativeEndian>(*self)
231 .map(|_| IsNull::No)
232 .map_err(|e| Box::new(e) as Box<_>)
233 }
234}
235
236impl<DB: MysqlLikeBackend> HasSqlType<Unsigned<TinyInt>> for DB {
237 fn metadata(_lookup: &mut ()) -> MysqlType {
238 MysqlType::UnsignedTiny
239 }
240}
241
242impl<DB: MysqlLikeBackend> HasSqlType<Unsigned<SmallInt>> for DB {
243 fn metadata(_lookup: &mut ()) -> MysqlType {
244 MysqlType::UnsignedShort
245 }
246}
247
248impl<DB: MysqlLikeBackend> HasSqlType<Unsigned<Integer>> for DB {
249 fn metadata(_lookup: &mut ()) -> MysqlType {
250 MysqlType::UnsignedLong
251 }
252}
253
254impl<DB: MysqlLikeBackend> HasSqlType<Unsigned<BigInt>> for DB {
255 fn metadata(_lookup: &mut ()) -> MysqlType {
256 MysqlType::UnsignedLongLong
257 }
258}
259
260#[cfg_attr(
279 feature = "jiff",
280 doc = " [`jiff::civil::DateTime`]: jiff::civil::DateTime"
281)]
282#[cfg_attr(
283 not(feature = "jiff"),
284 doc = " [`jiff::civil::DateTime`]: https://docs.rs/jiff/1/jiff/civil/struct.DateTime.html"
285)]
286#[cfg_attr(
287 feature = "chrono",
288 doc = " [`chrono::NaiveDateTime`]: chrono::naive::NaiveDateTime"
289)]
290#[cfg_attr(
291 not(feature = "chrono"),
292 doc = " [`chrono::NaiveDateTime`]: https://docs.rs/chrono/0.4.19/chrono/naive/struct.NaiveDateTime.html"
293)]
294#[cfg_attr(
295 feature = "time",
296 doc = " [`time::PrimitiveDateTime`]: time::PrimitiveDateTime"
297)]
298#[cfg_attr(
299 not(feature = "time"),
300 doc = " [`time::PrimitiveDateTime`]: https://docs.rs/time/0.3.9/time/struct.PrimitiveDateTime.html"
301)]
302#[cfg_attr(
303 feature = "time",
304 doc = " [`time::OffsetDateTime`]: time::OffsetDateTime"
305)]
306#[cfg_attr(
307 not(feature = "time"),
308 doc = " [`time::OffsetDateTime`]: https://docs.rs/time/0.3.9/time/struct.OffsetDateTime.html"
309)]
310#[derive(#[automatically_derived]impl ::core::fmt::Debug for Datetime {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "Datetime")
}
}Debug, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for Datetime {
}
#[automatically_derived]impl ::core::clone::Clone for Datetime {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for Datetime { }Copy, #[automatically_derived]impl ::core::default::Default for Datetime {
#[inline]
fn default() -> Self { Datetime {} }
}Default, const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for Datetime {
type QueryId = Datetime<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};QueryId, const _: () =
{
use diesel;
impl diesel::sql_types::SqlType for Datetime {
type IsNull = diesel::sql_types::is_nullable::NotNull;
const IS_ARRAY: bool = false;
}
impl diesel::sql_types::SingleValue for Datetime {}
impl diesel::sql_types::HasSqlType<Datetime> for diesel::mysql::Mysql
{
fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
diesel::mysql::MysqlType::DateTime
}
}
impl diesel::sql_types::HasSqlType<Datetime> for
diesel::mariadb::Mariadb {
fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
diesel::mariadb::MariadbType::DateTime
}
}
};SqlType)]
311#[diesel(mysql_type(name = "DateTime"))]
312#[diesel(mariadb_type(name = "DateTime"))]
313pub struct Datetime;
314
315#[cfg(all(test, any(feature = "mysql", feature = "mariadb")))]
316mod tests {
317 use super::*;
318
319 #[cfg(feature = "mysql")]
320 type DB = crate::mysql::Mysql;
321 #[cfg(feature = "mariadb")]
322 type DB = crate::mariadb::Mariadb;
323
324 #[diesel_test_helper::test]
325 fn empty_tiny_buffer_is_an_error() {
326 let empty = MysqlValue::new_internal(&[], MysqlType::Tiny);
327 assert!(<i8 as FromSql<TinyInt, DB>>::from_sql(empty).is_err());
328
329 let empty = MysqlValue::new_internal(&[], MysqlType::UnsignedTiny);
330 assert!(<u8 as FromSql<Unsigned<TinyInt>, DB>>::from_sql(empty).is_err());
331 }
332
333 #[diesel_test_helper::test]
334 fn tiny_buffers_keep_their_signedness() {
335 let signed = MysqlValue::new_internal(&[0xFF], MysqlType::Tiny);
336 assert_eq!(<i8 as FromSql<TinyInt, DB>>::from_sql(signed).unwrap(), -1);
337
338 let unsigned = MysqlValue::new_internal(&[200], MysqlType::UnsignedTiny);
339 assert_eq!(
340 <u8 as FromSql<Unsigned<TinyInt>, DB>>::from_sql(unsigned).unwrap(),
341 200
342 );
343 }
344
345 #[diesel_test_helper::test]
346 fn unsigned_tiny_above_i8_max_through_a_signed_sql_type() {
347 let raw = [200];
348
349 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedTiny);
351 assert!(<i8 as FromSql<TinyInt, DB>>::from_sql(v).is_err());
352
353 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedTiny);
354 assert_eq!(<i16 as FromSql<SmallInt, DB>>::from_sql(v).unwrap(), 200);
355 }
356
357 #[diesel_test_helper::test]
359 fn signed_value_through_an_unsigned_sql_type_is_an_error() {
360 let raw = [0xFF];
361 let v = MysqlValue::new_internal(&raw, MysqlType::Tiny);
362 assert!(<u8 as FromSql<Unsigned<TinyInt>, DB>>::from_sql(v).is_err());
363
364 let raw = (-1i16).to_ne_bytes();
365 let v = MysqlValue::new_internal(&raw, MysqlType::Short);
366 assert!(<u16 as FromSql<Unsigned<SmallInt>, DB>>::from_sql(v).is_err());
367
368 let raw = (-1i32).to_ne_bytes();
369 let v = MysqlValue::new_internal(&raw, MysqlType::Long);
370 assert!(<u32 as FromSql<Unsigned<Integer>, DB>>::from_sql(v).is_err());
371
372 let raw = (-1i64).to_ne_bytes();
373 let v = MysqlValue::new_internal(&raw, MysqlType::LongLong);
374 assert!(<u64 as FromSql<Unsigned<BigInt>, DB>>::from_sql(v).is_err());
375 }
376
377 #[diesel_test_helper::test]
378 fn unsigned_bigint_beyond_i64_through_a_signed_sql_type_is_an_error() {
379 let raw = u64::MAX.to_ne_bytes();
380 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLongLong);
381 assert!(<i64 as FromSql<BigInt, DB>>::from_sql(v).is_err());
382
383 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLongLong);
385 assert_eq!(
386 <u64 as FromSql<Unsigned<BigInt>, DB>>::from_sql(v).unwrap(),
387 u64::MAX
388 );
389 }
390
391 #[diesel_test_helper::test]
392 fn unsigned_bigint_at_i64_max_boundary() {
393 let raw = i64::MAX.to_ne_bytes();
395 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLongLong);
396 assert_eq!(<i64 as FromSql<BigInt, DB>>::from_sql(v).unwrap(), i64::MAX);
397
398 let raw = (i64::MAX as u64 + 1).to_ne_bytes();
400 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLongLong);
401 assert!(<i64 as FromSql<BigInt, DB>>::from_sql(v).is_err());
402 }
403
404 #[diesel_test_helper::test]
405 fn unsigned_bigint_beyond_i64_arriving_as_a_decimal() {
406 let v = MysqlValue::new_internal(b"18446744073709551615", MysqlType::Numeric);
407 assert_eq!(
408 <u64 as FromSql<Unsigned<BigInt>, DB>>::from_sql(v).unwrap(),
409 u64::MAX
410 );
411 }
412
413 #[diesel_test_helper::test]
414 fn unsigned_values_reaching_the_float_readers() {
415 let raw = 200u8.to_ne_bytes();
416 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedTiny);
417 assert_eq!(<f32 as FromSql<Float, DB>>::from_sql(v).unwrap(), 200.0);
418
419 let raw = 40000u16.to_ne_bytes();
420 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedShort);
421 assert_eq!(<f64 as FromSql<Double, DB>>::from_sql(v).unwrap(), 40000.0);
422
423 let raw = u32::MAX.to_ne_bytes();
424 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLong);
425 assert_eq!(
426 <f64 as FromSql<Double, DB>>::from_sql(v).unwrap(),
427 4_294_967_295.0
428 );
429 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLong);
430 assert_eq!(
431 <f32 as FromSql<Float, DB>>::from_sql(v).unwrap(),
432 4_294_967_296.0
433 );
434
435 let raw = u64::MAX.to_ne_bytes();
436 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLongLong);
437 assert_eq!(
438 <f64 as FromSql<Double, DB>>::from_sql(v).unwrap(),
439 18_446_744_073_709_551_616.0
440 );
441 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLongLong);
442 assert_eq!(
443 <f32 as FromSql<Float, DB>>::from_sql(v).unwrap(),
444 18_446_744_073_709_551_616.0
445 );
446 }
447
448 #[cfg(feature = "numeric")]
449 #[diesel_test_helper::test]
450 fn unsigned_values_reaching_the_decimal_reader() {
451 use bigdecimal::BigDecimal;
452
453 let raw = 200u8.to_ne_bytes();
454 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedTiny);
455 assert_eq!(
456 <BigDecimal as FromSql<Numeric, DB>>::from_sql(v).unwrap(),
457 BigDecimal::from(200u8)
458 );
459
460 let raw = 40000u16.to_ne_bytes();
461 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedShort);
462 assert_eq!(
463 <BigDecimal as FromSql<Numeric, DB>>::from_sql(v).unwrap(),
464 BigDecimal::from(40000u16)
465 );
466
467 let raw = u32::MAX.to_ne_bytes();
468 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLong);
469 assert_eq!(
470 <BigDecimal as FromSql<Numeric, DB>>::from_sql(v).unwrap(),
471 BigDecimal::from(u32::MAX)
472 );
473
474 let raw = u64::MAX.to_ne_bytes();
475 let v = MysqlValue::new_internal(&raw, MysqlType::UnsignedLongLong);
476 assert_eq!(
477 <BigDecimal as FromSql<Numeric, DB>>::from_sql(v).unwrap(),
478 BigDecimal::from(u64::MAX)
479 );
480 }
481}