|
1 | | -use byteorder::WriteBytesExt; |
2 | 1 | #[cfg(feature = "chrono")] |
3 | 2 | mod date_and_time; |
4 | 3 |
|
| 4 | +use byteorder::WriteBytesExt; |
5 | 5 | use mysql::{Mysql, MysqlType}; |
6 | 6 | use std::error::Error as StdError; |
7 | 7 | use std::io::Write; |
8 | | -use types::{self, ToSql, IsNull, FromSql, HasSqlType}; |
| 8 | +use types::{ToSql, IsNull, FromSql, HasSqlType}; |
9 | 9 |
|
10 | | -/// The tinyint SQL type. This is only available on MySQL. |
11 | | -/// |
12 | | -/// ### [`ToSql`](/diesel/types/trait.ToSql.html) impls |
13 | | -/// |
14 | | -/// - [`i8`][i8] |
15 | | -/// |
16 | | -/// ### [`FromSql`](/diesel/types/trait.FromSql.html) impls |
17 | | -/// |
18 | | -/// - [`i8`][i8] |
19 | | -/// |
20 | | -/// [i8]: https://doc.rust-lang.org/nightly/std/primitive.i8.html |
21 | | -#[derive(Debug, Clone, Copy, Default)] pub struct Tinyint; |
| 10 | +primitive_impls!(Tinyint -> (i8, mysql: (Tiny))); |
22 | 11 |
|
23 | | -impl ToSql<Tinyint, Mysql> for i8 { |
| 12 | +impl ToSql<::types::Tinyint, Mysql> for i8 { |
24 | 13 | fn to_sql<W: Write>(&self, out: &mut W) -> Result<IsNull, Box<StdError+Send+Sync>> { |
25 | 14 | out.write_i8(*self) |
26 | 15 | .map(|_| IsNull::No) |
27 | 16 | .map_err(|e| Box::new(e) as Box<StdError+Send+Sync>) |
28 | 17 | } |
29 | 18 | } |
30 | 19 |
|
31 | | -impl FromSql<types::Tinyint, Mysql> for i8 { |
| 20 | +impl FromSql<::types::Tinyint, Mysql> for i8 { |
32 | 21 | fn from_sql(bytes: Option<&[u8]>) -> Result<Self, Box<StdError+Send+Sync>> { |
33 | 22 | let bytes = not_none!(bytes); |
34 | 23 | Ok(bytes[0] as i8) |
35 | 24 | } |
36 | 25 | } |
37 | 26 |
|
38 | | -primitive_impls!(Tinyint -> (i8, mysql: (Tiny))); |
39 | | - |
40 | 27 | impl ToSql<::types::Bool, Mysql> for bool { |
41 | 28 | fn to_sql<W: Write>(&self, out: &mut W) -> Result<IsNull, Box<StdError+Send+Sync>> { |
42 | 29 | let int_value = if *self { |
|
0 commit comments